Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run initLogging unconditionally #1295

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ocrd_utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,8 @@ def disableLogging(silent=not config.OCRD_LOGGING_DEBUG):
# Python default log level is WARNING
logging.root.setLevel(logging.WARNING)

# Initialize logging now to prevent any other libraries (tensorflow,
# matplotlib ...) from adding their own root handler, which might mangle the
# STDOUT (our logging will log to STDERR so as not to interfere with
# --dump-json etc.)
initLogging()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's not what I meant. See #1223 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could still do initLogging on the module level, though not in ocrd_utils.logging but rather ocrd.decorators, which arguably will only be imported by applications that do need log handlers.

1 change: 1 addition & 0 deletions tests/cli/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _get_log_output(self, *args):

def setUp(self):
super().setUp()
disableLogging()
initLogging()

def tearDown(self):
Expand Down
Loading