From 2872b718cc8489601c99646ddba2af9a047acb99 Mon Sep 17 00:00:00 2001 From: dtk Date: Thu, 5 Jan 2012 03:20:33 +0100 Subject: Fix basic logging functionality This commit roughly restores the broken logging functionality. The first few messages are still logged to `stderr` as well as to the specified log file. Closes #170. --- alot/init.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'alot/init.py') diff --git a/alot/init.py b/alot/init.py index 5ce1d586..34d3810a 100755 --- a/alot/init.py +++ b/alot/init.py @@ -138,7 +138,12 @@ def main(): numeric_loglevel = getattr(logging, args['debug-level'].upper(), None) logfilename = os.path.expanduser(args['logfile']) logging.basicConfig(level=numeric_loglevel, filename=logfilename) + log_formatter = logging.Formatter('%(levelname)s:%(message)s') + log_handler = logging.FileHandler(logfilename, encoding='utf-8') + log_handler.setFormatter(log_formatter) logger = logging.getLogger() + logger.setLevel(numeric_loglevel) + logger.addHandler(log_handler) #logger.debug(commands.COMMANDS) # get ourselves a database manager -- cgit v1.2.3