From d1f586b4137cf249b6268eb838ac950e88b5a7eb Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Wed, 16 Jan 2013 18:53:32 +0700 Subject: [PATCH] Only configure logging handlers if not already present. --- rq/scripts/rqworker.py | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/rq/scripts/rqworker.py b/rq/scripts/rqworker.py index 43921f1..58553cf 100755 --- a/rq/scripts/rqworker.py +++ b/rq/scripts/rqworker.py @@ -15,32 +15,33 @@ logger = logging.getLogger(__name__) def setup_loghandlers(args): - logging.config.dictConfig({ - "version": 1, - "disable_existing_loggers": False, - - "formatters": { - "console": { - "format": "%(asctime)s %(message)s", - "datefmt": "%H:%M:%S", + 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"], + + "handlers": { + "console": { + "level": "DEBUG", + #"class": "logging.StreamHandler", + "class": "rq.utils.ColorizingStreamHandler", + "formatter": "console", + "exclude": ["%(asctime)s"], + }, }, - }, - "root": { - "handlers": ["console"], - "level": "DEBUG" if args.verbose else "INFO" - } - }) + "root": { + "handlers": ["console"], + "level": "DEBUG" if args.verbose else "INFO" + } + }) def parse_args(): @@ -91,3 +92,6 @@ def main(): except ConnectionError as e: print(e) sys.exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file