From f431432eb0cae58d29704afe75d6be64d2348767 Mon Sep 17 00:00:00 2001 From: Ignace Date: Wed, 26 Aug 2026 18:35:33 +0200 Subject: [PATCH] better cloud logging --- cloud/flask_home_control_log.py | 10 +++++++++- log/detect-arrivals.txt | 6 ++++++ service.yaml | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cloud/flask_home_control_log.py b/cloud/flask_home_control_log.py index f6145d2..c8f9467 100644 --- a/cloud/flask_home_control_log.py +++ b/cloud/flask_home_control_log.py @@ -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 "" diff --git a/log/detect-arrivals.txt b/log/detect-arrivals.txt index 81d7afa..eea9e1b 100644 --- a/log/detect-arrivals.txt +++ b/log/detect-arrivals.txt @@ -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 diff --git a/service.yaml b/service.yaml index ab6191d..83d9799 100644 --- a/service.yaml +++ b/service.yaml @@ -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.