test for log since last boot

This commit is contained in:
avollkopf 2024-05-02 07:08:23 +02:00
parent 1f56fa8fe1
commit 4ca441bba3
2 changed files with 17 additions and 2 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.4.1.a4"
__version__ = "4.4.1.a5"
__codename__ = "Yeast Starter"

View file

@ -146,7 +146,22 @@ class SystemController:
output_filename="cbpi4_log.zip"
if logtime == "b":
os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname))
if systemd_available:
#os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname))
j = journal.Reader()
j.add_match(_TRANSPORT="kernel")
result=[]
for entry in j:
message=entry['MESSAGE']
if message.find("Booting") != -1:
result.append(entry['__REALTIME_TIMESTAMP'])
j.add_match(_SYSTEMD_UNIT="craftbeerpi.service")
j.seek_realtime(result[-1])
for entry in j:
timestamp=entry['__REALTIME_TIMESTAMP']
message=entry['MESSAGE']
print(message)
else:
if systemd_available:
result=[]