Only configure logging handlers if not already present.

main
Selwin Ong 12 years ago
parent a247c6eaa1
commit d1f586b413

@ -15,32 +15,33 @@ logger = logging.getLogger(__name__)
def setup_loghandlers(args): def setup_loghandlers(args):
logging.config.dictConfig({ if not logging._handlers:
"version": 1, logging.config.dictConfig({
"disable_existing_loggers": False, "version": 1,
"disable_existing_loggers": False,
"formatters": {
"console": { "formatters": {
"format": "%(asctime)s %(message)s", "console": {
"datefmt": "%H:%M:%S", "format": "%(asctime)s %(message)s",
"datefmt": "%H:%M:%S",
},
}, },
},
"handlers": {
"handlers": { "console": {
"console": { "level": "DEBUG",
"level": "DEBUG", #"class": "logging.StreamHandler",
#"class": "logging.StreamHandler", "class": "rq.utils.ColorizingStreamHandler",
"class": "rq.utils.ColorizingStreamHandler", "formatter": "console",
"formatter": "console", "exclude": ["%(asctime)s"],
"exclude": ["%(asctime)s"], },
}, },
},
"root": { "root": {
"handlers": ["console"], "handlers": ["console"],
"level": "DEBUG" if args.verbose else "INFO" "level": "DEBUG" if args.verbose else "INFO"
} }
}) })
def parse_args(): def parse_args():
@ -91,3 +92,6 @@ def main():
except ConnectionError as e: except ConnectionError as e:
print(e) print(e)
sys.exit(1) sys.exit(1)
if __name__ == "__main__":
main()
Loading…
Cancel
Save