feat(logger): add CRITICAL log level
#1399
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of your changes
Currently the Logger utility supports only methods that are also supported by the
Consoleobject:warn,error,info, anddebug. On the other hand, Powertools for Python also supports acriticalmethod, this is because theloggingmodule that is part of the Python language supports it.When using Powertools for Python, customers can emit structured logs that contain the
"level": "CRITICAL"key/value. As reported in the linked issue, some of these customers might have setup alarms/metrics/queries that rely on this key/value being present in their logs.Given that Powertools for TypeScript doesn't support this method/level (yet), these customers are prevented from using both versions of Powertools interchangeably in their serverless workloads.
This PR tries to cater to these users by introducing a new
CRITICALlog level and method (Logger.critical). This new level has higher cardinality thanERRORmeaning that this is the less verbose one excludingSILENT. Logs emitted by callingLogger.criticalwill have"level": "CRITICAL"key/value.Notes on the implementation
As mentioned at the beginning, Node.js
Console's object doesn't have acriticalmethod. For this reason the Logger method introduced in this PR internally maps toconsole.error. This is done so that logs emitted using this method are forwarded tostderrjust like any other error.Once this PR is merged it closes #1395.
Related issues, RFCs
Issue number: #1395
Checklist
Breaking change checklist
Is it a breaking change?: NO
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.