better cloud logging

This commit is contained in:
2026-08-26 18:35:33 +02:00
parent 1e73476830
commit f431432eb0
3 changed files with 17 additions and 3 deletions
+9 -1
View File
@@ -36,7 +36,15 @@ def _tail(path: Path, line_count: int = 50) -> str:
logfile.seek(end)
data = logfile.read(size) + data
return b"\n".join(data.splitlines()[-line_count:]).decode("utf-8", "replace")
output = []
for raw_line in data.splitlines()[-line_count:]:
line = raw_line.decode("utf-8", "replace")
try:
event = json.loads(line).get("event", {})
output.append(str(event["text"]))
except (json.JSONDecodeError, AttributeError, KeyError, TypeError):
output.append(line)
return "\n".join(output)
except FileNotFoundError:
return ""
+6
View File
@@ -14,3 +14,9 @@
2026-08-26T18:05:14+02:00 ARRIVED id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:16:16+02:00 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:16:16+02:00 EMPTY id=house
2026-08-26T18:21:38+02:00 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:21:38+02:00 EMPTY id=house
2026-08-26T18:22:30+02:00 ARRIVED id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:22:31+02:00 FIRST_ARRIVAL id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:28:39+02:00 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
2026-08-26T18:28:40+02:00 EMPTY id=house
+2 -2
View File
@@ -71,8 +71,8 @@ notify:
cloud_logger:
enabled: true
# event_url: http://www.suy.nl/home_logger/event
event_url: http://127.0.0.1:29651/home_logger/event
event_url: https://www.suy.nl/home_logger/event
# event_url: http://127.0.0.1:29651/home_logger/event
timeout: 10
filter:
# Empty accept lists allow all values. Ignore lists always take precedence.