Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pycti/utils/opencti_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
import logging
from datetime import datetime, timezone

from pythonjsonlogger import jsonlogger

Expand All @@ -9,8 +9,8 @@ def add_fields(self, log_record, record, message_dict):
super(CustomJsonFormatter, self).add_fields(log_record, record, message_dict)
if not log_record.get("timestamp"):
# This doesn't use record.created, so it is slightly off
now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
log_record["timestamp"] = now
now = datetime.now(tz=timezone.utc)
log_record["timestamp"] = now.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log_record["timestamp"] = now.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
log_record["timestamp"] = now.isoformat()

if log_record.get("level"):
log_record["level"] = log_record["level"].upper()
else:
Expand Down