Skip to content

Commit

Permalink
fix: add UTC time to API logs (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov authored Nov 1, 2024
1 parent 564cad4 commit f0fcbcc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/logging_configuration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from datetime import datetime
from logging import Filter

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

asctime_format = "%Y-%m-%d %H:%M:%S,%f"
asctime = datetime.strptime(log_record.get("asctime"), asctime_format)

log_record["utctime"] = asctime.isoformat()

def format_json_on_new_lines(self, json_str):
# Parse the input JSON string
data = json.loads(json_str)
Expand Down

0 comments on commit f0fcbcc

Please sign in to comment.