Docs: child Logger without a parent uses the root log level since #8842

未關閉 適合新手
#8,935 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@rdxrahul12 已經在處理了。

開始於 2026年12月2日。

  • #8940 來自 @rdxrahul12 —— 未關閉

評估

難度
1/5
預估耗時
1-3 小時
新手友好度
85/100
Issue 類型
文件
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
documentation

研究方向

閱讀 docs/core/logger.md 中的 Child Loggers 章節和 caplog 提示(約第 969 行和第 1153 行)。更新它們,說明不存在父 Logger 時 root logger 的層級,以及測試如何設定層級或建立父 Logger。Issue 也建議新增 3.42.0 版本說明;請確認版本說明的位置並記錄行為變更。

由索引模型根據 Issue 內容生成。

描述

documentation triage
What were you searching in the docs?

How a child Logger behaves in tests when no parent Logger exists, after #8842 (merged, not released yet). I first raised it on the PR: https://github.com/aws-powertools/powertools-lambda-python/pull/8842#issuecomment-7171335297

Is this related to an existing documentation section?

https://docs.aws.amazon.com/powertools/python/latest/core/logger/#child-loggers

How can we improve?

Since #8842, a child Logger without a level stays NOTSET. With no parent Logger in the process, it inherits the root logger's level (WARNING), so logger.info() is dropped. That matches 3.5.0, but on 3.6.0 to 3.41.0 it logged INFO. This test passes on 3.41.0 and fails on develop:

# shared.py
from aws_lambda_powertools import Logger

logger = Logger(service="payment", child=True)


def charge():
    logger.info("charged")


# test_shared.py
import shared


def test_charge_logs(caplog):
    shared.charge()
    assert "charged" in caplog.text

The docs don't cover this case: not the Child Loggers section (docs/core/logger.md line 969), and not the caplog tip under Testing your code (line 1153).

Got a suggestion in mind?
  • docs/core/logger.md line 969, add: "If no parent Logger with the same service exists, the child uses the root logger's level (WARNING by default)."
  • Line 1153, add to the caplog tip: "If the module under test only defines a child Logger, call caplog.set_level(logging.INFO) or create the parent Logger in conftest.py."
  • A line in the 3.42.0 release notes, since users on 3.6.0 or later have only seen INFO.

I can open a PR for the two docs lines. An AI assistant helped me write the test scripts; I ran them on 3.41.0 and develop and checked the output myself.

Acknowledgment
  • I understand the final update might be different from my proposed suggestion, or refused.
主要語言
Python
星號
3.3k
分支
511
平均合併
2 天 23 小時
30 天內合併 PR
50

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aws-powertools/powertools-lambda-python 的其他 Issue

查看 aws-powertools/powertools-lambda-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。