Folks,
I\'m scratching my head on a python logging config that I can\'t get right.
Let\'s say I have the following package installed:
mypacka
An approach to update your handler:
import logging
from rootmodule.mymodule import mylogger
def update_handler_level(logger, handler_type, level="INFO"):
# if not root logger user logger.parent
for handler in logger.handlers or logger.parent.handlers:
if isinstance(handler, handler_type):
print(handler.level)
handler.setLevel(getattr(logging, level, "INFO"))
print(handler.level)
mylogger.debug('test')
update_handler_level(mylogger, logging.StreamHandler)
mylogger.debug('test')
My logging.cfg is pretty similar than your except the fact that the logger name si set in a constant module (a can do module rename without breaking the logging configuration)
To update from command line, you must have a mapping between your opts value and logging.Handler sub class name.