Skip to content

fix(logger): route log, warn, and fatal through buffer dispatch - #8871

Open
dhairyakhandelwal880-dotcom wants to merge 1 commit into
aws-powertools:developfrom
dhairyakhandelwal880-dotcom:fix/logger-log-fatal-warn-buffering
Open

dhairyakhandelwal880-dotcom wants to merge 1 commit into
aws-powertools:developfrom
dhairyakhandelwal880-dotcom:fix/logger-log-fatal-warn-buffering

Conversation

@dhairyakhandelwal880-dotcom

@dhairyakhandelwal880-dotcom dhairyakhandelwal880-dotcom commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: closes #8827

Summary

Changes

  • Replaced duplicated buffer handling across logger methods with an internal _log() dispatcher.
  • Added log(self, level, msg, *args, **kwargs) to route through the buffer and auto-flush on error log.
  • Added warn = warning and fatal = critical aliases.
  • Updated buffer record frame depth to accurately preserve caller stack frames when dispatching through _log().

User experience

Before this change, calling logger.log(), logger.warn(), or logger.fatal() bypassed buffer routing and flush-on-error logic. Now they respect buffer_at_verbosity and flush buffered logs upon error or critical log levels.

Verification

  • Added regression tests in tests/functional/logger/required_dependencies/test_powertools_logger_buffer.py:
    • test_logger_log_method_buffers_and_flushes_on_error
    • test_logger_warn_and_fatal_aliases
  • All 31 buffer tests passed locally.
  • Verified with ruff check.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logger 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(), fatal() and warn() bypass buffering and flush-on-error

1 participant