From b78047f604fbfa681bbb50e2bbcb6390332f105e Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Tue, 13 Dec 2011 13:01:28 -0600 Subject: [PATCH] Log levels as string does not work on Python 2.6.x I thought that was new. Turns out it just disables logging if you use a string as well so that was lovely to figure out. --- bucky/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bucky/main.py b/bucky/main.py index f2d9041..a8cc680 100644 --- a/bucky/main.py +++ b/bucky/main.py @@ -167,6 +167,13 @@ def load_config(cfgfile, full_trace=False): def configure_logging(): + levels = { + 'debug': logging.DEBUG, + 'info': logging.INFO, + 'warning': logging.WARNING, + 'error': logging.ERROR, + 'critical': logging.CRITICAL + } logfmt = "[%(levelname)s] %(module)s - %(message)s" handler = logging.StreamHandler() handler.setFormatter(logging.Formatter(logfmt)) @@ -174,8 +181,8 @@ def configure_logging(): logging.root.addHandler(handler) logging.root.setLevel(logging.DEBUG) if cfg.debug: - cfg.log_level = "DEBUG" - handler.setLevel(cfg.log_level) + cfg.log_level = "debug" + handler.setLevel(levels.get(cfg.log_level.lower(), logging.INFO)) if __name__ == '__main__':