-
Notifications
You must be signed in to change notification settings - Fork 403
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
refactor(logger): BYOFormatter and Handler, UTC support, and more #404
refactor(logger): BYOFormatter and Handler, UTC support, and more #404
Conversation
@heitorlessa nice, this would help alot when you have company mandated structured logging formats. |
@bml1g12 - what are your thoughts on the UTC UX for your use case? Anything else you need while I'm at it? |
Currently, I am declaring in each handler
So in this new UX I would instead simply do
In each handler and the child would inherit this right? If so, looks great to me! Much appreciated addition. |
Yes exactly. I noticed you’re using RFC 8601 in your datefmt, I’ll make
sure this will be the default timestamp in v2, as changing now would break
customers.
…On Wed, 21 Apr 2021 at 08:06, Benjamin Lowe ***@***.***> wrote:
Currently, I am declaring in each handler
LOGGER = Logger(datefmt="%Y-%m-%dT%H:%M:%SZ")
LOGGER._logger.handlers[0].formatter.converter = time.gmtime #pylint: disable = protected-access
So in this new UX I would instead simply do
LOGGER = Logger(datefmt="%Y-%m-%dT%H:%M:%SZ", utc=True)
In each handler and the child would inherit this right?
If so, looks great to me! Much appreciated addition.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#404 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBA6QLUPK7IESZ3EUXTTJZTORANCNFSM43FYVHHQ>
.
|
Nice! Yes I chose this as I saw a few blogs recommending it as a standard across languages for structured logging; I think its the default for javascript time logging maybe for example |
@heitorlessa I am liking these changes so long, I am glad to see that now even |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a minor tweak and typo
Co-authored-by: Michael Brewer <[email protected]>
Codecov Report
@@ Coverage Diff @@
## develop #404 +/- ##
===========================================
- Coverage 99.94% 99.89% -0.06%
===========================================
Files 98 100 +2
Lines 3688 3816 +128
Branches 174 176 +2
===========================================
+ Hits 3686 3812 +126
- Misses 0 1 +1
- Partials 2 3 +1
Continue to review full report at Codecov.
|
…orlessa/aws-lambda-powertools-python into refactor/decouple-formatter * 'refactor/decouple-formatter' of https://github.com/heitorlessa/aws-lambda-powertools-python: Update aws_lambda_powertools/logging/formatter.py
Issue #, if available: #381 #387 #215 #98
Description of changes:
Major refactor of Logger to a) make it more flexible for those coming from other loggers, b) bring your own formatter for those with a common structure that differs from our opinionated one, c) UX enhancements to add or remove keys from the logger, d) address long standing tech debts on
LambdaPowertoolsFormatter
.UTC support
New convenience property to change logger handler, if necessary
Bring your own handler
Bring your own formatter
Updating formatter made easier
Checklist
Logger(log_formatter=...)
append_keys
andremove_keys
append_keys
for Lambda decorator andstructure_log
callsutc=True
timestamp
keyformatTime
is overridenappend_keys
,remove_keys
overstructure_log(append=True)
to align with other runtimesseparators[]
to remove whitespace)Create separate PR for docs to include enhancements:
orjson
for those seeking to gain every possible microsecondTesting your code
section to include how to usestream=sys.stdout
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.