Skip to content
Browse files

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.
  • Loading branch information...
1 parent d3949b9 commit b78047f604fbfa681bbb50e2bbcb6390332f105e @davisp davisp committed Dec 13, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 bucky/main.py
View
11 bucky/main.py
@@ -167,15 +167,22 @@ 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))
handler.setLevel(logging.ERROR) # Overridden by configuration
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__':

0 comments on commit b78047f

Please sign in to comment.
Something went wrong with that request. Please try again.