-
Notifications
You must be signed in to change notification settings - Fork 146
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
Bug: child logger with overwritten options clear all other options #1163
Comments
@dreamorosi hi, let's fix this! 😉 Maybe you copy-pasted the debugging logs wrong, so there isn't an undefined value for the I ran the snippet in my lambda, and it logged I will look at it and come up with a plan. |
Hey @shdq, indeed I copy-pasted the logs wrong. I just checked and it's like you say (which is the issue I was trying to report). Thank you for stepping up on this, I'll assign the issue to you and will be happy to collaborate. |
Hello @dreamorosi I hope you're doing well. The problem in this line in
I created a Frankenstein, that fix that issue, but it should be killed 😁
Let's keep going, we have parent and child:
if we create a grandson from the child:
It works with
I haven't tested other options. It may require to patch many things. Test every possible config option is possible, but not easy to maintain. There is a chance to miss something. I think it can be solved completely. What if we "store" custom options when a parent is created? We can merge them later with new options used in Pros:
Another thought was to "read" from the parent's options which are different from the default. Like Thoughts? I'm still exploring the project and could miss something. |
Hi @shdq, doing well, hope you are too! Thanks for looking into this and producing the report. I agree that we should let Frankie go 😄
Looking at the "pros" that you shared, the prospect of removing one dependency is pretty attractive and when stacked against the additional field(s) and slightly expanded logic in the I think we can move forward with that and continue the discussion over a PR. |
|
Expected Behaviour
When creating a child logger (see "Code snippet" section) and passing some options the child logger should retain all the parent properties/options except the ones explicitly overwritten.
Current Behaviour
The child logger won't have all the same options that the parent has whenever the user creates the logger while also passing some options to overwrite. For example:
From the example above, I would expect
auditLogger
to have the sameserviceName
aslogger
and only differ insampleRateValue
- however as you can see from the logs in the "Debugging logs" section,serviceName
is undefined inauditLogger
.Code snippet
Possible Solution
Rework the
createChild
function in Logger to account for passed options and add unit tests to confirm fix & prevent future regressions.Steps to Reproduce
Deploy a function using the code shared in the "Code snippet" section, then execute it, finally observe the logs (see example in Debugging logs section).
AWS Lambda Powertools for TypeScript version
latest
AWS Lambda function runtime
16.x
Packaging format used
Npm
Debugging logs
The text was updated successfully, but these errors were encountered: