diff options
author | dtk <dtk@gmx.de> | 2012-01-05 17:15:34 +0100 |
---|---|---|
committer | dtk <dtk@gmx.de> | 2012-01-05 17:22:35 +0100 |
commit | b3c19e05ace15c94962b2d32f5e7612704e39fd2 (patch) | |
tree | bbddcbb5ab6c1a0bc7fff6301e475dee2ce4cc26 /alot | |
parent | d2599fe506ab6156ee7f2513caf64cc6a03d3b29 (diff) |
Reset logging before configuring
Some unknown piece of code causes the `logging` lib to create a default
configuration, which includes a logging level of `logging.WARNING` and a
`StreamHandler`. The existence of this default configuration prevents our call
to `logging.basicConfig()` to set the configured values, which leads to `debug`
and `info` messages not being logged and all messages being streamed to `stderr`
(which is controlled and gets flushed by `urwid`) instead of being written to
the configured log file.
This commit removes the existing `StreamHandler` before calling
`logging.basicConfig()` which makes the latter install the desired logging
configuration.
Closes #170.
Diffstat (limited to 'alot')
-rwxr-xr-x | alot/init.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/alot/init.py b/alot/init.py index d9405078..07e5771b 100755 --- a/alot/init.py +++ b/alot/init.py @@ -134,7 +134,13 @@ def main(): except ConfigParser.Error, e: # exit on parse errors sys.exit(e) - # setup logging + # logging + ## reset + root_logger = logging.getLogger() + for log_handler in root_logger.handlers: + root_logger.removeHandler(log_handler) + root_logger = None + ## setup numeric_loglevel = getattr(logging, args['debug-level'].upper(), None) logfilename = os.path.expanduser(args['logfile']) logformat = '%(levelname)s:%(module)s:%(message)s' |