Skip to content
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

Feature request: support CRITICAL log level #1395

Closed
2 tasks done
H1Gdev opened this issue Apr 2, 2023 · 2 comments · Fixed by #1399
Closed
2 tasks done

Feature request: support CRITICAL log level #1395

H1Gdev opened this issue Apr 2, 2023 · 2 comments · Fixed by #1399
Assignees
Labels
feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility

Comments

@H1Gdev
Copy link

H1Gdev commented Apr 2, 2023

Use case

I would like to monitor lambda function logs by level key. (using Amazon CloudWatch)

In another lambda function(using Python), ERROR and CRITICAL are already used properly, so I would like to use them differently in new lambda function(using Node.js) under the same conditions.

Node.js and Java do not provide critical level.

Ref. #1392

Solution/User Experience

  • Add CRITICAL.
  • Add critical method in Logger class.

Alternative solutions

No response

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@H1Gdev H1Gdev added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Apr 2, 2023
@dreamorosi dreamorosi added logger This item relates to the Logger Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Apr 3, 2023
@dreamorosi
Copy link
Contributor

Hi @H1Gdev thank you for taking the time to open this feature request following our previous discussion.

For the benefit of future readers, I'll include here my initial response as for why Powertools for Python supports this log level while this library doesn't:

Powertools for Python builds on top of Python's logging module that is part of the standard library. As such, that version of Powertools supports the same levels that the logging module supports:

Level Numeric Value
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0

Node.js on the other hand, deals with logs differently and doesn't have a strict level structure like Python does. The closest thing to Python's logging library in Node.js is the Console object.

The Console object does have some methods like info, debug, warn, error, etc. but doesn't have a concept of levels, and most importantly for this discussion, doesn't have a method that maps to CRITICAL. In Node.js, using one method or the other only influences whether the log will be emitted to stdout or stderr with warn and error going to stderr and all others going to stdout.

In Powertools for Typescript however the log level doesn't just influence the which Console method will be used to log, but it also influences the fact that logs will contain a level key (see docs).


While as mentioned the log level doesn't have a correspondent in Node.js, I see value in aligning the output of Logger between this library with the Python version. In this way, users who operate functions in both languages can use the same queries, dashboards, and alarms on these logs.

In our implementation, Logger will accept the CRITICAL log level which under the hood will map to console.error and emit to stderr. From the log and output perspective there will be no difference between calling logger.error and logger.critical except for the fact that the latter will contain level: "CRITICAL" as key.

I'll move this to the backlog to be implemented.

@dreamorosi dreamorosi self-assigned this Apr 3, 2023
@dreamorosi dreamorosi linked a pull request Apr 7, 2023 that will close this issue
13 tasks
@github-project-automation github-project-automation bot moved this from Backlog to Coming soon in AWS Lambda Powertools for TypeScript Apr 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2023

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues 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.

@dreamorosi dreamorosi removed the confirmed The scope is clear, ready for implementation label Apr 7, 2023
@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Apr 7, 2023
@dreamorosi dreamorosi removed the pending-release This item has been merged and will be released soon label Apr 11, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in AWS Lambda Powertools for TypeScript Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants