Skip to content

[BugFix] Fix root logger configuration being modified by PaddleOCR imports - #18247

Open
nandanadileep wants to merge 2 commits into
PaddlePaddle:mainfrom
nandanadileep:fix/logging-root-logger-pollution
Open

nandanadileep wants to merge 2 commits into
PaddlePaddle:mainfrom
nandanadileep:fix/logging-root-logger-pollution

Conversation

@nandanadileep

@nandanadileep nandanadileep commented Jul 7, 2026

Copy link
Copy Markdown

Motivation

Importing paddleocr triggers dependency imports (e.g., paddlex, paddle) that may modify the root logger's level or handlers. This causes issues where users who configure logging *before* importing PaddleOCR find their log output silenced after the import.

Modifications

  • paddleocr/__init__.py: Save the root logger's level and handler list before module imports, then restore them after all imports complete. This ensures PaddleOCR does not interfere with the calling application's logging configuration.
  • tests/unit/test_logging_restore.py: Added unit tests validating the save/restore mechanism handles level changes, handler additions, handler removals, and the no-op case.

Usage or Command

N/A

Accuracy Tests

N/A - logging change only, no model accuracy impact.

Checklist

  • Add at least a tag in the PR title.
  • Format your code, run pre-commit before commit.
  • Add unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the main branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

Closes #14955

@nandanadileep nandanadileep changed the title [BugFix] Fix root logger level being modified by PaddleOCR imports [BugFix] Fix root logger configuration being modified by PaddleOCR imports Jul 7, 2026
@paddle-bot

paddle-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thanks for your contribution!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

paddleocr的log设置会影响到调用模块的log级别设置

1 participant