-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Description
The following warning occurs:
/home/sasaki/workspace/orcas_proj/venv/lib/python3.12/site-packages/logstash/formatter.py:73: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
tstamp = datetime.utcfromtimestamp(time)
Modify the format_timestamp method around line 73 of logstash/formatter.py as follows:
- Before the fix
@classmethod
def format_timestamp(cls, time):
tstamp = datetime.utcfromtimestamp(time)
return tstamp.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (tstamp.microsecond / 1000) + "Z"
- After correction (sample)
@classmethod
def format_timestamp(cls, time):
from datetime import datetime, timezone # <-Please write at the beginning of the line
tstamp = datetime.fromtimestamp(time, tz=timezone.utc)
return tstamp.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (tstamp.microsecond / 1000) + "Z"
Metadata
Metadata
Assignees
Labels
No labels