Skip to content

fix(logger): include the call stack when stack_info=True - #8951

Open
sumedh-aerram wants to merge 1 commit into
aws-powertools:developfrom
sumedh-aerram:fix/logger-stack-info
Open

sumedh-aerram wants to merge 1 commit into
aws-powertools:developfrom
sumedh-aerram:fix/logger-stack-info

Conversation

@sumedh-aerram

@sumedh-aerram sumedh-aerram commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Issue number:

closes #8950

Summary

Changes

LambdaPowertoolsFormatter never wrote record.stack_info, so logger.info(..., stack_info=True) dropped the call stack. format() now adds it under a stack_info key. The value is None unless the caller asks for it, and None is already stripped, so other log lines don't change. The Logger docs get a short "Logging the call stack" section with an example.

User experience

The log line now has "stack_info": "Stack (most recent call last): ...", as the standard library prints it, including for buffered records.

Verification

Three new functional tests: two fail on develop and pass with the fix, and one confirms the key is absent by default. Logger tests pass on Python 3.10 and 3.14. The full suite (4182 passed), ruff, mypy and pre-commit pass. No AWS service is involved.

I used an AI assistant (Claude) to help write this change. I ran every check and reviewed the diff myself.


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.

@sumedh-aerram
sumedh-aerram requested a review from a team as a code owner December 4, 2026 00:27
@sumedh-aerram
sumedh-aerram requested a review from svozza December 4, 2026 00:27
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation logger tests labels Dec 4, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

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

documentation Improvements or additions to documentation 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: Logger drops the call stack when a log call passes stack_info=True

1 participant