mirror of https://github.com/peter4431/rq.git
Update cli.py to support custom loggers (#1906)
* Update cli.py to support custom loggers Allows a config.py file (via rq worker --config) to support things like this for logfmt logging: DICT_CONFIG = { "version": 1, "formatters": {"logfmt": { "()": "logfmter.Logfmter", "keys": ["level","when","pid"], "mapping": {"level":"levelname","when":"asctime","pid":"process"}, "datefmt": "%Y-%m-%dT%H:%M:%S%z" }}, "handlers": {"console": {"class": "logging.StreamHandler","formatter": "logfmt" }}, "loggers": { "root": {"handlers":["console"], "level": "INFO"}, "rq": {"handlers":["console"], "level": "INFO", "propagate": False}, } } * added simple test and documentation for DICT_CONFIG * further attempt to get testing right for dictConfig * move import to correct location * fix * remove meaningless options.get() usage * linting checks and added missing test config filemain
parent
bdbc9a4f9c
commit
107221fd9e
@ -0,0 +1,19 @@
|
|||||||
|
# example config taken from <https://stackoverflow.com/a/7507842/784804>
|
||||||
|
DICT_CONFIG = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'formatters': {
|
||||||
|
'standard': {'format': 'MY_LOG_FMT: %(asctime)s [%(levelname)s] %(name)s: %(message)s'},
|
||||||
|
},
|
||||||
|
'handlers': {
|
||||||
|
'default': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'formatter': 'standard',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'stream': 'ext://sys.stdout', # Default is stderr
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'root': {'handlers': ['default'], 'level': 'DEBUG', 'propagate': False}, # root logger
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue