Skip to content

chore: Console output overrides lambda console out #936

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 3 commits into from
Jul 22, 2025

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Jul 21, 2025

Please provide the issue number

Issue number: #932

Summary

Changes

This pull request refactors the ConsoleWrapper class to improve its handling of console output in AWS Lambda environments and enhance testability. It introduces new methods for determining and overriding console output, removes deprecated logic, and updates the test suite to ensure comprehensive coverage of the changes.

Refactoring of ConsoleWrapper:

  • Removed the _outputResetPerformed flag and replaced EnsureConsoleOutputOnce with EnsureConsoleOutput, which uses the new ShouldOverrideConsole method to decide when to override console output. [1] [2] [3] [4]
  • Added ShouldOverrideConsole and HasLambdaReInterceptedConsole methods to improve the detection of whether console output should be overridden in Lambda environments.
  • Enhanced error handling in OverrideLambdaLogger to prevent crashes if console override fails.

Test Suite Enhancements:

  • Refactored ConsoleWrapperTests to include setup and teardown logic for isolating test state, ensuring reliable test execution.
  • Added new test cases to validate behavior in Lambda and non-Lambda environments, including scenarios where Lambda re-intercepts console output or console override fails. [1] [2]
  • Removed outdated tests for _outputResetPerformed and replaced them with updated tests for the new logic.

Code Cleanup:

  • Fixed a typo in variable naming (errordOutput to errorOutput) and improved code readability.
  • Deprecated the ClearOutputResetFlag method but retained it for backward compatibility, ensuring it does not throw errors. [1] [2]

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 21, 2025
@boring-cyborg boring-cyborg bot added area/common Core Powertools utility tests labels Jul 21, 2025
@hjgraca hjgraca linked an issue Jul 21, 2025 that may be closed by this pull request
@github-actions github-actions bot added the internal Maintenance changes label Jul 21, 2025
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.35%. Comparing base (c2711e2) to head (49b66e8).
Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
...WS.Lambda.Powertools.Common/Core/ConsoleWrapper.cs 92.30% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #936      +/-   ##
===========================================
+ Coverage    77.31%   77.35%   +0.04%     
===========================================
  Files          271      271              
  Lines        10839    10864      +25     
  Branches      1277     1280       +3     
===========================================
+ Hits          8380     8404      +24     
+ Misses        2043     2042       -1     
- Partials       416      418       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@hjgraca hjgraca requested a review from leandrodamascena July 22, 2025 09:48
@hjgraca hjgraca merged commit 3cd704a into develop Jul 22, 2025
9 checks passed
@hjgraca hjgraca deleted the fix/override-lambda-console branch July 22, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/common Core Powertools utility internal Maintenance changes size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Log messages not being output as structured content
2 participants