Skip to content

feat(logger): flush buffer on uncaught error decorator #3676

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

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

dreamorosi
Copy link
Contributor

Summary

Changes

Please provide a summary of what's being changed

This PR adds a new parameter to the injectLambdaContext() class method decorator that allows customers to optionally flush a log buffer whenever their function handler throws an error.

The PR also makes slight updates to some of the docstrings in the Logger class that were added during previous PRs, and updates the unit tests for the feature to reduce nesting.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3635


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 Feb 28, 2025
@dreamorosi dreamorosi requested review from a team as code owners February 28, 2025 11:23
@dreamorosi dreamorosi requested a review from am29d February 28, 2025 11:23
@boring-cyborg boring-cyborg bot added logger This item relates to the Logger Utility tests PRs that add or change tests labels Feb 28, 2025
@pull-request-size pull-request-size bot added the size/XL PRs between 500-999 LOC, often PRs that grown with feedback label Feb 28, 2025
@dreamorosi dreamorosi requested review from Copilot and am29d and removed request for am29d February 28, 2025 11:23
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Feb 28, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces the ability to flush the log buffer when an uncaught error occurs in a Lambda handler decorated with injectLambdaContext. Key changes include:

  • Adding the flushBufferOnUncaughtError option to the injectLambdaContext decorator.
  • Updating docstrings to reflect the new functionality and improve clarity.
  • Extending unit tests to cover buffer flushing behavior on uncaught errors.
  • Introducing a new constant, UncaughtErrorLogMessage, to standardize the error message logged on uncaught errors.

Reviewed Changes

File Description
packages/logger/src/Logger.ts Enhancements in the injectLambdaContext decorator and docstrings
packages/logger/tests/unit/logBuffer.test.ts Additional tests covering buffer flushing on uncaught errors
packages/logger/src/constants.ts New constant for uncaught error log messages
packages/logger/src/types/Logger.ts Update to InjectLambdaContextOptions to include flushBufferOnUncaughtError

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@dreamorosi dreamorosi merged commit 28db2e3 into main Feb 28, 2025
41 checks passed
@dreamorosi dreamorosi deleted the feat/logger_flush_on_error_decorator branch February 28, 2025 14:44
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 logger This item relates to the Logger Utility size/XL PRs between 500-999 LOC, often PRs that grown with feedback tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: flush buffer on uncaught error - class method decorator
2 participants