-
Notifications
You must be signed in to change notification settings - Fork 31
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
ocrd_utils.initLogging: also add handler to root logger #1288
base: master
Are you sure you want to change the base?
Conversation
…tent with file config and prevent imported libraries from initing logging first), but disable propagation for ocrd loggers (to avoid duplication)
But if This said, the |
Yes, the idea was to behave unintrusively as a library but as you point out, in practice we don't
Agreed.
🙏 Let's discuss on Monday, I'm all for pushing for a clean logging because that is high on the list of most painful aspects of the OCR-D software at the moment. |
What do you mean not working at all? Operandi can have its own If the application is a standalone OCR-D CLI (→
Sry, I don't understand that at all. |
Actually, I was trying to point out that we do. We do not call |
Not logging anything, and if
Yes, but there is some kind of interference because of the I am talking about the experience I had in the past. Maybe these issues are no longer there. I am not sure, because I have my hack to reconfigure the loggers at run-time after the
I was talking about the |
I will try to unwrap: Operandi on startup calls ocrd_utils.initLogging. So you are saying that
Also, have you tried calling
I don't understand how our package data log config can interfere at all, unless It sounds like what you describe has been observed when core would still do
I would hope so. Could you please try it out – perhaps even with and without this change here?
Ok, that's quite involved (I don't fully understand the InterceptHandler). Side effects being handlers and levels you don't want? (So it could also be the same issue as above?)
So you were merely saying that an optional file config should not interfere with programmatic setup? I agree – and that's what |
Because it has to be called when using core methods, and there is no workaround to avoid it (may no longer be valid).
That may be the case, yes. I will have to verify again.
Yes, absolutely. Take for instance just core (the latest version) - the The only place where everything is logged as expected to a file is the
Yes. It is not that optional in the end since core provides a default for you and the only way to avoid that is to provide a manual logging configuration file. |
As a follow-up to ccb416b, but more general:
initLogging
should always affect the root logger''
, too. (Not just when disabling logging.)Reasons:
root
logger for our default handlersimport tensorflow
) – the place to check whether logging has been set up yet is alwaysgetLogger('').hasHandlers()
, also in Python's logging.basicConfig BTWI know we deliberately changed this to exclude the root logger earlier. But I cannot find the reasoning behind that anymore. Maybe "we are a library, not an application"? Well, I agree actually, but then just don't call
initLogging
. (Perhaps at that time we got distracted by the fact that we still did callinitLogging
unconditionally when importingocrd_utils.logging
.)BTW, IMO most places (core and modules code) can get their loggers from Python stdlib's
logging.getLogger
instead of ourocrd_utils.logging.getLogger
, because we don't add anything to that nowadays.