-
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
fix(logger): enable logging of arbitrary objects #883
Conversation
@dreamorosi Ready for review |
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.
Looking good, I'm going to run the integration tests on this branch: https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/2347203386
Can you add such object log in the e2e tests as well ? |
Run with the latest changes: https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/2351346144 |
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.
Thanks for opening this PR!
I have some questions about the choice of making the types more loose than they were before.
While making the types very loose (unknown
is the most loose type we can use), we can still keep the existing types and allow for nested objects to be added anyway.
If there are some struggle with making the types work (I know they can be a pain :-)), I am happy to support/ help out myself with those and improve the existing types, rather than using unknown
.
Also I would like us to cover a more diverse scenarios that include nested objects with different types next to the one where the object value is a string.
packages/logger/tests/e2e/basicFeatures.middy.test.FunctionCode.ts
Outdated
Show resolved
Hide resolved
E2E test is failing (link), it seems for a missing module (so before running the actual tests). We need to investigate further. |
@dreamorosi I haven't changed anything in the modules. In fact, we already had a similar issue with my first PR. The issue was caused by a faulty commit on |
Yes, please, let's try to rebase. |
@dreamorosi I double checked and can confirm that my branch is based on the latest |
@saragerion Thanks for your comments! I replied directly in the threads. I also updated the tests to operate on complex and nested objects of various types. To your main question: why
The latest E2E test run is passing. |
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.
Thanks for the work on this topic, really appreciate it!
* fix(logger): enable logging of arbitrary objects * Update docs * Add E2E test * Use nested objects in tests * Update usage docs
* fix(logger): enable logging of arbitrary objects * Update docs * Add E2E test * Use nested objects in tests * Update usage docs
Description of your changes
This PR relaxes the restrictions introduced by #614. In #565, we decided to restrict the additional logging data objects in their shape. It turned out, that this restriction prevents from logging of arbitrary objects, which is inconvenient.
In this PR, the type restrictions are removed, so it is now possible to specify any object as additional payload when calling the logger methods directly.
How to verify this change
No compile time errors should be generated for the above example. The code should generate a valid log entry when executed.
Related issues, RFCs
#880
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.