Only add logging handler if nothing is configured.

main
Selwin Ong 11 years ago
parent 8095a565ac
commit 92fb787a69

@ -11,32 +11,15 @@ try:
except ImportError: except ImportError:
from rq.compat.dictconfig import dictConfig # noqa from rq.compat.dictconfig import dictConfig # noqa
from rq.utils import ColorizingStreamHandler
def setup_loghandlers(level=None):
if not logging._handlers:
dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'console': {
'format': '%(asctime)s %(message)s',
'datefmt': '%H:%M:%S',
},
},
'handlers': { def setup_loghandlers(level=None):
'console': { logger = logging.getLogger()
'level': 'DEBUG', if not logger.handlers:
# 'class': 'logging.StreamHandler', logger.setLevel(level)
'class': 'rq.utils.ColorizingStreamHandler', formatter = logging.Formatter(fmt='%(asctime)s %(message)s',
'formatter': 'console', datefmt='%H:%M:%S')
'exclude': ['%(asctime)s'], handler = ColorizingStreamHandler()
}, handler.setFormatter(formatter)
}, logger.addHandler(handler)
'root': {
'handlers': ['console'],
'level': level or 'INFO',
}
})

Loading…
Cancel
Save