From 672635819458e4ab8145c8f25bd11ff34bd16f32 Mon Sep 17 00:00:00 2001 From: Matteo Ferrando Date: Tue, 29 Oct 2024 23:14:11 -0400 Subject: [PATCH 1/2] feat: add log timestamp when processing --- src/isolate/logger.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/isolate/logger.py b/src/isolate/logger.py index 424514e..4bcce50 100644 --- a/src/isolate/logger.py +++ b/src/isolate/logger.py @@ -1,5 +1,6 @@ import json import os +from datetime import datetime, timezone from typing import Dict from isolate.logs import LogLevel, LogSource @@ -16,6 +17,9 @@ def __init__(self, log_labels: Dict[str, str]): def log(self, level: LogLevel, message: str, source: LogSource) -> None: record = { + # Set the timestamp from source so we can be sure no buffering or + # latency is affecting the timestamp. + "timestamp": datetime.now(tz=timezone.utc).isoformat(), "isolate_source": source.name, "level": level.name, "message": message, From c4e8ca5de2be79aafacf49139318f733be645c5b Mon Sep 17 00:00:00 2001 From: Matteo Ferrando Date: Tue, 29 Oct 2024 23:18:35 -0400 Subject: [PATCH 2/2] use different name to avoid confusion --- src/isolate/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isolate/logger.py b/src/isolate/logger.py index 4bcce50..23e4f5e 100644 --- a/src/isolate/logger.py +++ b/src/isolate/logger.py @@ -19,7 +19,7 @@ def log(self, level: LogLevel, message: str, source: LogSource) -> None: record = { # Set the timestamp from source so we can be sure no buffering or # latency is affecting the timestamp. - "timestamp": datetime.now(tz=timezone.utc).isoformat(), + "logged_at": datetime.now(tz=timezone.utc).isoformat(), "isolate_source": source.name, "level": level.name, "message": message,