Update root logging - #2129
Merged
Merged
Conversation
felixdittrich92
force-pushed
the
logging-update
branch
from
August 19, 2026 09:54
38ddfb4 to
39402e7
Compare
Closed
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
loggingmodule with module-level loggers (e.g.,logger = logging.getLogger(__name__)) across multiple files, includingdoctr/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, anddoctr/utils/reconstitution.py. All logging calls now use the module-levelloggerinstead oflogging. [1] [2] [3] [4] [5] [6] [7]In
doctr/cli/main.py, introduced a_setup_loggingfunction 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 theloggerobject, and_setup_loggingis called inmain. [1] [2]Linter Configuration Update
LOG015(logging-fstring-interpolation) from the Ruff linter configuration inpyproject.toml, enforcing stricter logging practices. Where necessary, added# noqa: LOG015to lines that would otherwise trigger this warning, such as inreferences/classification/train_character.pyandreferences/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.