Skip to content

Commit

Permalink
Log levels as string does not work on Python 2.6.x
Browse files Browse the repository at this point in the history
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
davisp committed Dec 13, 2011
1 parent d3949b9 commit b78047f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bucky/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit b78047f

Please sign in to comment.