Skip to content

Update root logging - #2129

Merged
felixdittrich92 merged 4 commits into
mindee:mainfrom
felixdittrich92:logging-update
Aug 19, 2026
Merged

Update root logging#2129
felixdittrich92 merged 4 commits into
mindee:mainfrom
felixdittrich92:logging-update

Conversation

@felixdittrich92

@felixdittrich92 felixdittrich92 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors logging throughout the codebase to use module-level loggers instead of the root logger, improving logging control and avoiding unwanted log output from dependencies. It also introduces a dedicated logging setup for the CLI to prevent handler stacking and ensures consistent logging practices across modules. Additionally, a linter ignore for a specific logging rule (LOG015) is removed from the configuration, and necessary in-line disables are added where appropriate.

Logging Refactor and Improvements

  • Replaced all direct uses of the root logging module with module-level loggers (e.g., logger = logging.getLogger(__name__)) across multiple files, including doctr/cli/main.py, doctr/file_utils.py, doctr/models/factory/hub.py, doctr/models/utils/pytorch.py, doctr/utils/data.py, doctr/utils/fonts.py, and doctr/utils/reconstitution.py. All logging calls now use the module-level logger instead of logging. [1] [2] [3] [4] [5] [6] [7]

  • In doctr/cli/main.py, introduced a _setup_logging function for CLI logging configuration. This ensures that only doctr logs are output and avoids stacking handlers when the CLI is invoked multiple times. All CLI logging now uses the logger object, and _setup_logging is called in main. [1] [2]

Linter Configuration Update

  • Removed the ignore for LOG015 (logging-fstring-interpolation) from the Ruff linter configuration in pyproject.toml, enforcing stricter logging practices. Where necessary, added # noqa: LOG015 to lines that would otherwise trigger this warning, such as in references/classification/train_character.py and references/classification/train_orientation.py. [1] [2] [3]

Consistency and Error Handling

CLI and Utility Enhancements

  • Ensured that repeated CLI invocations do not stack logging handlers by naming and managing handlers explicitly in the CLI logging setup.

  • Updated all utility functions and CLI operations to use the new logger, improving maintainability and debuggability. [1] [2] [3]

These changes collectively improve the reliability, maintainability, and clarity of logging throughout the project.

@felixdittrich92 felixdittrich92 self-assigned this Aug 19, 2026
@felixdittrich92 felixdittrich92 added the type: misc Miscellaneous label Aug 19, 2026
@felixdittrich92
felixdittrich92 merged commit 89fd51b into mindee:main Aug 19, 2026
54 checks passed
@felixdittrich92
felixdittrich92 deleted the logging-update branch August 19, 2026 10:01
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.06%. Comparing base (e59b917) to head (39402e7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
doctr/cli/main.py 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2129      +/-   ##
==========================================
- Coverage   97.07%   97.06%   -0.01%     
==========================================
  Files         169      169              
  Lines        9976     9992      +16     
==========================================
+ Hits         9684     9699      +15     
- Misses        292      293       +1     
Flag Coverage Δ
unittests 97.06% <97.56%> (-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

type: misc Miscellaneous

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant