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

feat(logger): add CRITICAL log level #1399

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Apr 7, 2023

Description of your changes

Currently the Logger utility supports only methods that are also supported by the Console object: warn, error, info, and debug. On the other hand, Powertools for Python also supports a critical method, this is because the logging module 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 CRITICAL log level and method (Logger.critical). This new level has higher cardinality than ERROR meaning that this is the less verbose one excluding SILENT. Logs emitted by calling Logger.critical will have "level": "CRITICAL" key/value.

Notes on the implementation

As mentioned at the beginning, Node.js Console's object doesn't have a critical method. For this reason the Logger method introduced in this PR internally maps to console.error. This is done so that logs emitted using this method are forwarded to stderr just like any other error.

Once this PR is merged it closes #1395.

Related issues, RFCs

Issue number: #1395

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

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.

@dreamorosi dreamorosi self-assigned this Apr 7, 2023
@dreamorosi dreamorosi linked an issue Apr 7, 2023 that may be closed by this pull request
2 tasks
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Apr 7, 2023
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Apr 7, 2023
@dreamorosi
Copy link
Contributor Author

See successful integration test run that includes the content of this PR: https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/4638129072

@dreamorosi dreamorosi marked this pull request as ready for review April 7, 2023 13:06
@dreamorosi dreamorosi merged commit a248ff0 into main Apr 7, 2023
@dreamorosi dreamorosi deleted the 1395-feature-support-critical-log-level branch April 7, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs that introduce new features or minor changes size/L PRs between 100-499 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: support CRITICAL log level
1 participant