Skip to content

Do not use root logger#2082

Open
lachesis wants to merge 2 commits into
mindee:mainfrom
lachesis:lachesis/no-root-logger
Open

Do not use root logger#2082
lachesis wants to merge 2 commits into
mindee:mainfrom
lachesis:lachesis/no-root-logger

Conversation

@lachesis

Copy link
Copy Markdown
Contributor

Calling logging.info() at module level with no logger configured triggers logging.basicConfig() automatically (Python's "last resort" behavior) — which creates a StreamHandler on root with WARNING level.

This poisons logging config for anything downstream of this.

Instead, create a logger scoped to doctr package.

Example repro script:

#!/usr/bin/env python
from doctr.io import Document

import logging
logging.basicConfig(level=logging.INFO)

logging.info("I do not see this")
logging.warning("I still see this")

Output:

WARNING:root:I still see this

Expected:

INFO:root:I do not see this
WARNING:root:I still see this

Replaces #2076

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.96%. Comparing base (9c1c6e3) to head (5923734).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2082      +/-   ##
==========================================
+ Coverage   96.94%   96.96%   +0.01%     
==========================================
  Files         156      156              
  Lines        7535     7535              
==========================================
+ Hits         7305     7306       +1     
+ Misses        230      229       -1     
Flag Coverage Δ
unittests 96.96% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant