Bug: child Logger without a level ignores its parent's log level since 3.6.0
维护者通常 1 天内回复
@saimcyber 已经在做这个了。
开始于 2026年11月12日。
评估
调研方向
issue 指出子 Logger 的级别处理和 refresh_sample_rate_calculation() 是受影响的行为,但没有提供文件或测试路径。先追踪 Python 包中 Logger 的构造和采样率刷新过程,然后查找相关的 logger 测试。完成标准是:未显式指定级别的子 Logger 遵循父 Logger 配置并采样后的级别,而具有自身级别的子 Logger 保留该级别;为报告的情况添加测试。
由索引模型根据 Issue 内容生成。
描述
Expected Behaviour
A child Logger (Logger(child=True)) created without a level should follow its parent's log level: a level set in the parent's constructor, later setLevel() calls, and debug sampling. That's how it worked up to 3.5.0, and it's what the docs describe: "All state changes will be propagated bi-directionally between Child and Parent."
Current Behaviour
Since 3.6.0 (#5950), a child without a level always ends up at INFO (or at POWERTOOLS_LOG_LEVEL when that's set) and stops following its parent:
- parent
level="DEBUG",setLevel("DEBUG")orsampling_rate=1: the child's DEBUG logs are dropped - parent
level="WARNING": the child still emits INFO - a child that decorates the handler with
POWERTOOLS_LOGGER_SAMPLE_RATEset: every warm invocation resets it to INFO child.log_levelalways reports 20
#5950 was meant to let a child use its own level when one is passed. It also changed children that don't pass one.
Code snippet
# shared.py
from aws_lambda_powertools import Logger
logger = Logger(child=True) # service comes from POWERTOOLS_SERVICE_NAME=payment
def work():
logger.debug("child debug")
logger.info("child info")
# app.py
import shared
from aws_lambda_powertools import Logger
logger = Logger(level="DEBUG") # same with logger.setLevel("DEBUG") or Logger(sampling_rate=1)
shared.work()
# 3.5.0: prints "child debug" and "child info"
# 3.6.0+: prints only "child info" <- the child's DEBUG log is lost
Possible Solution
Only call setLevel on a child when a level is passed, so it stays NOTSET and inherits like before. The same goes for the level refresh_sample_rate_calculation() restores for a child. log_level should then return the effective level, so a child reports the level it actually logs at. I have a fix with tests ready and can open a PR once this is triaged.
Steps to Reproduce
- Put the two files above in a folder and set
POWERTOOLS_SERVICE_NAME=payment. pip install aws-lambda-powertools==3.38.0, then runpython app.py: only "child info" is printed.pip install aws-lambda-powertools==3.5.0and run it again: both lines are printed.
Did you run the reproduction yourself?
Yes, I ran it and saw the failure
Powertools for AWS Lambda (Python) version
3.38.0 (broken since 3.6.0)
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
Child Logger without a level, same two-module app on each version:
parent 3.5.0 3.6.0 - 3.38.0
level="DEBUG" / setLevel("DEBUG") / sampling DEBUG+INFO INFO only
sampling decorator, 2 warm invocations both INFO only
level="WARNING" nothing child INFO leaks
child.log_level (parent DEBUG) 0 20
- 主要语言
- Python
- 星标
- 3.3k
- 派生
- 511
- 平均合并
- 3 天 8 小时
- 30 天内合并 PR
- 103
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws-powertools/powertools-lambda-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
aws-powertools/powertools-lambda-python#8801 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
aws-powertools/powertools-lambda-python#8800 ·
维护者通常 1 天内回复
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation可能已有人在做 @lechakrawarthy 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8728 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET可能已有人在做 @coughlmao 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8727 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 seconds可能已有人在做 @CJstate 于 11 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 75/100
aws-powertools/powertools-lambda-python#8726 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 aws-powertools/powertools-lambda-python 的全部 Issue
相似的 Issue
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
难度 2/5 1-3 小时 新手友好度 78/100
Huerte/algo-solutions-python#254 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 86/100
MichaelYcJo/SpecSeal#1543 ·
-
size/s
难度 1/5 1 小时以内 新手友好度 90/100
sipyourdrink-ltd/bernstein#7179 ·
维护者通常 1 天内回复
-
good first issue help wanted python up-for-grabs
难度 2/5 1-3 小时 新手友好度 65/100
andrewsiah/agentswarm-data-tasks#309 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复