better cloud logging
This commit is contained in:
@@ -36,7 +36,15 @@ def _tail(path: Path, line_count: int = 50) -> str:
|
|||||||
logfile.seek(end)
|
logfile.seek(end)
|
||||||
data = logfile.read(size) + data
|
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:
|
except FileNotFoundError:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
@@ -14,3 +14,9 @@
|
|||||||
2026-08-26T18:05:14+02:00 ARRIVED id=ignace mac=ce:68:53:a8:fc:07
|
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 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
|
||||||
2026-08-26T18:16:16+02:00 EMPTY id=house
|
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
@@ -71,8 +71,8 @@ notify:
|
|||||||
|
|
||||||
cloud_logger:
|
cloud_logger:
|
||||||
enabled: true
|
enabled: true
|
||||||
# event_url: http://www.suy.nl/home_logger/event
|
event_url: https://www.suy.nl/home_logger/event
|
||||||
event_url: http://127.0.0.1:29651/home_logger/event
|
# event_url: http://127.0.0.1:29651/home_logger/event
|
||||||
timeout: 10
|
timeout: 10
|
||||||
filter:
|
filter:
|
||||||
# Empty accept lists allow all values. Ignore lists always take precedence.
|
# Empty accept lists allow all values. Ignore lists always take precedence.
|
||||||
|
|||||||
Reference in New Issue
Block a user