Skip to content

Timezone aware timestamp logging #379

@bml1g12

Description

@bml1g12

What were you initially searching for in the docs?
How to log the timezone in a timezone aware format ("2019-02-04T12:23:34Z" ISO 8601 ) e.g. to guarantee UTC time is always logged, even when logging in JST, or to at least indicate the time zone.

Describe how we could make it clearer

I can see how with this library we can specify a format string for the datetime, and I think datetime is hard coded to come from https://docs.python.org/3/library/time.html#time.asctime asctime() if I understand correctly, which in turn means that we are logging in time-zone unaware local time.

The documentation is unclear (if it is even possible) on how to log in a timezone aware manner.

They say here that "Python datetime objects don't have time zone info by default, and without it, Python actually violates the ISO 8601 specification (if no time zone info is given, assumed to be local time). You can use the pytz package to get some default time zones, or directly subclass tzinfo yourself"
https://stackoverflow.com/questions/19654578/python-utc-datetime-objects-iso-format-doesnt-include-z-zulu-or-zero-offset

So if I wanted to say log in strict ISO 8601 specification, or ensure my logs are always UTC no matter where the code is run, I am unclear how to do this?

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions