Mercurial > moin > 1.9
changeset 5916:881d9053592a
logging: if the logging config file can't be read, give a helpful error msg
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 16 Jan 2013 16:16:42 +0100 |
parents | 19e8a1c50bda |
children | c99f570e274a |
files | MoinMoin/log.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/log.py Tue Jan 08 00:07:30 2013 +0100 +++ b/MoinMoin/log.py Wed Jan 16 16:16:42 2013 +0100 @@ -120,7 +120,15 @@ if conf_fname: try: conf_fname = os.path.abspath(conf_fname) - logging.config.fileConfig(conf_fname) + # we open the conf file here to be able to give a reasonable + # error message in case of failure (if we give the filename to + # fileConfig(), it silently ignores unreadable files and gives + # unhelpful error msgs like "No section: 'formatters'"): + f = open(conf_fname) + try: + logging.config.fileConfig(f) + finally: + f.close() configured = True l = getLogger(__name__) l.info('using logging configuration read from "%s"' % conf_fname)