-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation on using custom date format for logging #946
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @kishaningithub - have you seen this part of the docs? If so, was it helpful? https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/#overriding-log-records We should totally make a dedicated section to esse discovering either way - thank you so much for helping us improve the docs! |
@heitorlessa Thanks for pointing me to this section of the documentation. Originally I had skipped this section (viz "Migrating from other loggers") because i was creating a new project from scratch. This section is definitely useful :-) Given RFC3339 is such a common thing now, for ease of use i am also thinking why not create a helper method which returns the |
Great idea! Would you like to contribute it as a static method within
Logger?
Source class:
https://github.com/awslabs/aws-lambda-powertools-python/blob/3e4e1abaebea360c01752726b62af8b805bbe3ac/aws_lambda_powertools/logging/logger.py#L48
I'd be more than happy to review/guide. If you can't, we can tackle after
reviewing the new tutorial docs section and MyPy fixes
…On Tue, 11 Jan 2022 at 11:03, Kishan B ***@***.***> wrote:
@heitorlessa <https://github.com/heitorlessa> Thanks for pointing me to
this section of the documentation. Originally I had skipped this section
(viz "Migrating from other loggers") because i was creating a new project
from scratch. This section is definitely useful :-)
Given RFC3339 is such a common thing now, for ease of use i am also
thinking why not create a helper method which returns the datefmt string
for this format. This can be used while instantiating the logger.
—
Reply to this email directly, view it on GitHub
<#946 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBBVWIOVLXT26Z3EFCLUVP575ANCNFSM5LVNBDXA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I will do it @heitorlessa Thanks for your support |
hey @kishaningithub following up on this :) An efficient and extensible way to do this could be as constants. That way, it could be easier to document, keep Logger clean, allow reusing for any other loggers in the future, and allow future contributions with variations of it. e.g. pseudo code, doesn't have to be this way app.py from aws_lambda_powertools.logging import date_formats
logger = Logger(datefmt=date_formats.RFC3339)
logger = Logger(datefmt=date_formats.ISO8601) aws_lambda_powertools/logging/date_formats.py RFC3339 = "<format>"
ISO8601 = "<format>"
# any variation, or formats that might require datetime str |
hey @kishaningithub following up to confirm you still have the bandwidth to make this contribution - if you do, please do not hesitate to ask for help (here or on our discord) |
Assigning this to myself to make it available in the next release @kishaningithub @JJSphar I've had a head-scratching moment when trying to find the differences between ISO8601 and RFC3339 (an extension/profile of ISO8601). After a lot of trial and error, luckily, someone built a tool to isolate with formats that show the interception and where they don't agree with each other. Here's a breakdown of challenges and decisions so we can always come back to this later if needed:
Quick representation of default and this new option
UXfrom aws_lambda_powertools import Logger
logger = Logger(use_rfc3339_iso8601=True) |
In my opinion RFC3339 is a stricter version of ISO8601. Golang's std library only supports RFC3339 which feels like a right choice to me to apply in other places |
This sounds great! I think the format you listed would cover a lot of common use cases. Personally, my lambdas use a wrapper class around |
Draft PR is up: #1662 @kishaningithub @JJSphar could I please ask you to double check whether that format and UX address the original ask? I'll document tomorrow if that suffice. I've added an internal note so that we move to that format in V3, add appropriate warnings in the future, and more importantly to not cause a breaking change. Thank you for your patience. |
I like |
yes, thank @leandrodamascena for that great suggestion :D |
|
This is now released under 2.1.0 version! |
What were you initially searching for in the docs?
I was searching for a way to use ISO8601 especially the RFC3339 variant while printing the event time stamps. Then i found this discussion link #905 (comment)
Is this related to an existing part of the documentation? Please share a link
https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/#
Describe how we could make it clearer
I would be really helpful if we can provide an example of how to change the timeformat to RFC3339 in the documentation site here
If you have a proposed update, please share it here
Example on how to instantiate logger using RFC3339 format
The text was updated successfully, but these errors were encountered: