Browse Source

web/lib/utils.py: add workaround for django

It helps to avoid multiple root loggers.
pull/1/head
Hidden Z 14 years ago
parent
commit
489f1c9f15
  1. 7
      web/lib/utils.py

7
web/lib/utils.py

@ -8,6 +8,10 @@ from logging import handlers
def get_logger(filename=None, log_level='debug'): def get_logger(filename=None, log_level='debug'):
""" Prepare logger instance for our scripts """ """ Prepare logger instance for our scripts """
# workaround for django
if hasattr(logging, "web_logger"):
return logging.web_logger
LEVELS = { LEVELS = {
'debug': logging.DEBUG, 'debug': logging.DEBUG,
'info': logging.INFO, 'info': logging.INFO,
@ -27,6 +31,9 @@ def get_logger(filename=None, log_level='debug'):
handler.setFormatter(formatter) handler.setFormatter(formatter)
logger.addHandler(handler) logger.addHandler(handler)
# workaround for django
logging.web_logger = logger
return logger return logger

Loading…
Cancel
Save