mirror of https://github.com/peter4431/rq.git
Have Worker.work() setup logging.
Basically, I don't want to enforce users to configure _any_ logging stack when writing a basic worker, like this: from rq import Worker, Queue, Connection with Connection(): q = Queue() w = Worker([q]) w.work(burst=True) In case you want to disable logging altogether, you can configure your logging stack to do so.main
parent
40d0a7d9a9
commit
37b3bb4bd4
@ -0,0 +1,31 @@
|
|||||||
|
import logging.config
|
||||||
|
|
||||||
|
|
||||||
|
def setup_loghandlers(verbose=False):
|
||||||
|
if not logging._handlers:
|
||||||
|
logging.config.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"
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue