Open bertsky opened 5 months ago
@kba you commented
Changes as of 2023-08-20:
- 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
But how did you intend to effect that all loggers (e.g. processor.Tesserocr
) are inheriting from ocrd
?
More explanation on #1080:
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.
Again, I don't quite get it. How can this work with all the loggers we use in the wild, the least of which actually derive from ocrd
? (For example, we have ocrd_network.*
and processor.*
...)
So perhaps as a workaround we could move the other loggers under ocrd
(i.e. ocrd.ocrd_network.*
, ocrd.processor.*
etc.). But what about other loggers we wanted to affect in ocrd_logging.conf (e.g. shapely
, PIL
or tensorflow
)?
Also, it seems that the log config file (e.g. ~/ocrd_logging.conf
) still takes precedence: If I run ocrd-tesserocr-recognize with --log-level ERROR
I can still see ocrd.workspace.save_image_file
messages with INFO
level...
It seems that with https://github.com/OCR-D/core/commit/269670528c40aec694a5704bce1be189d1a3102a we lost the ability to control all loggers at once from the CLI.