mirror of https://github.com/peter4431/rq.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
import logging
|
|
|
|
# Make sure that dictConfig is available
|
|
# This was added in Python 2.7/3.2
|
|
try:
|
|
from logging.config import dictConfig
|
|
except ImportError:
|
|
from rq.compat.dictconfig import dictConfig # noqa
|
|
|
|
|
|
def setup_loghandlers(verbose=False):
|
|
if not logging._handlers:
|
|
dictConfig({
|
|
"version": 1,
|
|
"disable_existing_loggers": False,
|
|
|
|
"formatters": {
|
|
"console": {
|
|
"format": "%(asctime)s %(message)s",
|
|
"datefmt": "%H:%M:%S",
|
|
},
|
|
},
|
|
|
|
"handlers": {
|
|
"console": {
|
|
"level": "DEBUG",
|
|
#"class": "logging.StreamHandler",
|
|
"class": "rq.utils.ColorizingStreamHandler",
|
|
"formatter": "console",
|
|
"exclude": ["%(asctime)s"],
|
|
},
|
|
},
|
|
|
|
"root": {
|
|
"handlers": ["console"],
|
|
"level": "DEBUG" if verbose else "INFO"
|
|
}
|
|
})
|