You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to easily log in a timezone aware manner; a typical use case being to always log in UTC time, regardless of where the code is run. At present, the Powertools Logger() uses localtime for the timestamp field as under the hood it uses the asctime() method.
Describe alternatives you've considered
I raised this issue as a documentation query at first #379 and @heitorlessa kindly helped me find a workaround to this there using monkeypatching or overwritting the formatter.
It can be a new feature for Logger to have a flag to convert to UTC or a given offset, which I agree would be a useful feature as I imagine many users would desire the ability to ensure the timestamp is UTC. For example, this is actually a requirement if one wished to log strictly according to the ISO 8601 standard.
Thanks again for creating the feature request @bml1g12 - In the meantime, I've updated the docs with that fix until we decide on the best way to implement this for everyone ;)
cc @saragerion@pankajagrawal16 this is a great chance on using our brand new RFCs repo and make it public - I'm sure this will be asked at some point for Typescript and Java too
@bml1g12 I completely agree with your proposal. Local time is calculated based on the context of the current machine and that might be different from the developer local time.
It's important that all logs generate use the same common "timezone".
The TypeScript Powertool is supporting ISO 8601 by default, and the timezone is always zero UTC offset. Developers can choose to customize the format if they want.
What do you think?
Activity
heitorlessa commentedon Apr 9, 2021
Thanks again for creating the feature request @bml1g12 - In the meantime, I've updated the docs with that fix until we decide on the best way to implement this for everyone ;)
https://awslabs.github.io/aws-lambda-powertools-python/develop/core/logger/#setting-timestamp-to-utc
cc @saragerion @pankajagrawal16 this is a great chance on using our brand new RFCs repo and make it public - I'm sure this will be asked at some point for Typescript and Java too
saragerion commentedon Apr 9, 2021
@bml1g12 I completely agree with your proposal. Local time is calculated based on the context of the current machine and that might be different from the developer local time.
It's important that all logs generate use the same common "timezone".
The TypeScript Powertool is supporting ISO 8601 by default, and the timezone is always zero UTC offset. Developers can choose to customize the format if they want.
What do you think?
heitorlessa commentedon May 6, 2021
This is now out in 1.15.0: #423.
logger = Logger(service="example", utc=True);)