Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit f0fcbcc

Browse files
fix: add UTC time to API logs (#917)
1 parent 564cad4 commit f0fcbcc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

utils/logging_configuration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from datetime import datetime
23
from logging import Filter
34

45
from pythonjsonlogger.jsonlogger import JsonFormatter
@@ -9,6 +10,11 @@ class BaseLogger(JsonFormatter):
910
def add_fields(self, log_record, record, message_dict):
1011
super(BaseLogger, self).add_fields(log_record, record, message_dict)
1112

13+
asctime_format = "%Y-%m-%d %H:%M:%S,%f"
14+
asctime = datetime.strptime(log_record.get("asctime"), asctime_format)
15+
16+
log_record["utctime"] = asctime.isoformat()
17+
1218
def format_json_on_new_lines(self, json_str):
1319
# Parse the input JSON string
1420
data = json.loads(json_str)

0 commit comments

Comments
 (0)