Additional log level: TRACE
Use case
Create an additional log level of TRACE below DEBUG
DEBUG contains statements about entering specific functions, iterations of a loop, timing info, etc. as well as actual data such as function parameters, API responses etc.
INFO is reserved for normal informational messages, like logging the results of an invocation but not all the intermediate details.
TRACE level would allow DEBUG to only contain the data, API responses, etc. and TRACE then contains the statements for the execution path.
Solution/User Experience
Add an additional level for TRACE as was done for CRITICAL.
Alternative solutions
No response
Acknowledgment
- [X] This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- [X] Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link
Hi @codyfrisch, thank you for taking the time to open an issue on our repo and for explaining the reasoning behind this new log level.
At least on the surface I see the addition of a VERBOSE level in between DEBUG and INFO as somewhat confusing as it's not immediately clear (to me at least) where it sits on the level scale.
Having a TRACE level below DEBUG on the other hand, makes me immediately think about more information than DEBUG.
Before making a decision I'd like to leave the conversation open for a while and give the chance to other customers to share what they think about the above and whether this new level could be useful for their use cases.
@dreamorosi I see what you mean. A TRACE level would cover all of the statements about execution path - which is what I want to hide. Then DEBUG would cover details about all the data involved.
log4j2 and .net core both have TRACE. Python does not have a language level TRACE but does have a NOTSET level below DEBUG. Seems both Python and Typescript loggers could benefit from a TRACE level at least within the Powertools logger.
Since none have verbose, I am going to change my mind and say TRACE is the clearest choice for a path forward.
BTW thanks for the ability to set log level dynamically.
I have just started to adopt powertools and configured lambda with advanced logging controls for the first time. I expected the log levels in the logger package to match the levels mentioned by aws. This would mean that TRACE is more detailed than DEBUG and CRITICAL should be renamed or become an alias for FATAL.
Hi @timo92 - we have a section in our Logger docs dedicated to explaining how Powertools for AWS Lambda Logger interacts with AWS Lambda Advanced Logging Controls (ALC).
In short, if your function emits logs exclusively using our Logger, the only log levels that make sense from ALC as of today are DEBUG through ERROR, because we don't have corresponding methods to emit logs at FATAL and TRACE levels.
I agree that the current experience is not as good as it could be, and ideally we should support all levels supported by ALC either by adding the ones that are missing (TRACE) or aliasing existing ones (CRITICAL -> FATAL).
Seeing as this is now getting traction, perhaps because people are starting to adopt ALC, I'm going to put this item on the backlog and open it for contributions in case anyone is interested.
@timo92 - For FATAL, if possible, I would ask you to please open a separate feature request so we can address the item separately and keep changes focused/scoped.
--
For this issue, we should make the following changes:
- Add a new log level threshold here for
TRACEwith value6 - Add a new public method to Logger called
tracethat has a similar implementation to this method except it uses6as threshold value. - Modify the
LoggerInterfacehere to include the new method - Add the new
TRACEmethod at the top of thisLogLevelmap - Add new test cases for the new method here to ensure that code coverage remains at 100%
- Update the documentation here to include the new log level
[!note] For those interested in contributing, please leave a comment below so that we can assign the issue to you and make sure we don't duplicate efforts. Also, if you have any further questions please don't hesitate to ask here or on our Discord channel.
@dreamorosi Feel free to asign this issue to me
⚠️ COMMENT VISIBILITY WARNING ⚠️
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.