Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kba
Copy link
Member

@kba kba commented Aug 20, 2023

From the module description:

  • Try to be less intrusive with OCR-D specific logging conventions to
    make it easier and less surprising to define logging behavior when
    using OCR-D/core as a library
  • Change setOverrideLogLevel to only override the log level of the ocrd
    logger and its descendants
  • initLogging will set exactly one handler, for the root logger or for the
    ocrd logger.
  • Child loggers should propagate to the ancestor logging (default
    behavior of the logging library - no more PropagationShyLogger)
  • disableLogging only removes any handlers from the ocrd logger

In short:

  • if you want the OCR-D logging conventions, use ocrd_utils.logging.{initLogging,getLogger,disableLogging}.
  • if you don't want OCR-D to mess with the root logger, call initLogging(basic_config=False)
  • if you want the builtin logging behavior only, call initLogging(builtin_only) which will omit the configuration file lookup
  • if you don't want the OCR-D logging conventions, just do not use them. The only side effect of (transitively) importing ocrd_utils.logging now is that all handlers added to the ocrd logger will be removed. I'm open for even removing that but need to think about it some more.

Until now, we implemented --log-level/setOverrideLoglevel by changing the default logger to one that does not propagate and overriding the levels of every logger. Now, we keep the default behavior (all loggers propagate) and only change the level of the ocrd logger. We leave the root logger alone completely.

@kba kba requested a review from MehmedGIT September 4, 2023 13:33
@kba kba marked this pull request as ready for review September 8, 2023 10:19
@kba
Copy link
Member Author

kba commented Sep 12, 2023

It's finally passing all the tests, let's merge before another one breaks ;)

@kba kba merged commit 8006c98 into master Sep 12, 2023
@kba kba deleted the revise-logging branch September 12, 2023 14:01
@kba kba mentioned this pull request Sep 15, 2023
@bertsky
Copy link
Collaborator

bertsky commented May 23, 2024

@kba 2696705 broke the existing API because setOverrideLogLevel used to handle OCR-D level names like OFF, but now does not anymore. Can we get the old behaviour getLevelName back please?

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.

4 participants