Skip to content

Commit

Permalink
use of timezone for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianClemenz authored and lnagel committed Nov 21, 2024
1 parent bc53318 commit 2aa140a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion django_datadog_logger/formatters/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import typing
from logging import LogRecord

try:
import zoneinfo
except ImportError:
from backports import zoneinfo

import json_log_formatter
from django.conf import settings
from django.core.exceptions import DisallowedHost
Expand Down Expand Up @@ -77,7 +82,7 @@ def json_record(self, message: str, extra: typing.Dict, record: LogRecord) -> ty
"logger.thread_name": record.threadName,
"logger.method_name": record.funcName,
"date": (
datetime.datetime.fromtimestamp(record.created, tz=datetime.UTC).isoformat()
datetime.datetime.fromtimestamp(record.created, tz=zoneinfo.ZoneInfo("UTC")).isoformat()
),
"status": record.levelname,
}
Expand Down

0 comments on commit 2aa140a

Please sign in to comment.