Closed lukasjuhrich closed 2 years ago
As it turns out, the reason is that the logger has been instantiated with logging.Logger
and not logging.getLogger
, yielding a fresh object which is completely unknown to the logging.Logger.manager.loggerDict
. Changing to logger = logging.getLogger(__name__)
fixes everything.
In
hades.bin.lease_server
, the call tosetup_cli_logging
correctly sets everything up. However, calls to e.g.logger.info
reference the old, unconfigured object which was instantiated at import time. For instance, the following log call does not work even when callinghades-lease-server
with-vvv
: https://github.com/agdsn/hades/blob/78782831b840188b14e37c0673a6d6e9712f64ce/src/hades/bin/lease_server.py#L50-L52…because the logger has been instantiated at import time: https://github.com/agdsn/hades/blob/78782831b840188b14e37c0673a6d6e9712f64ce/src/hades/bin/lease_server.py#L22
Indeed, setting a breakpoint there, we get the following:
I see two ways to mitigate that:
logger
aftersetup_cli_logging(…)
and directly pass it as a parameter when necessarylogger
objects in already importedhades
modules byglobal logger; logger = logging.getLogger(__name__)
after thesetup_cli_logging(…)
call.