diff MoinMoin/log.py @ 5931:c14974df2b58

logging configuration: use info loglevel for telling about using the builtin default logging config often, logging is not configured as the default builtin fallback configuration is fine for most cases. thus, we should just tell, but not WARN. if loading some configuration from a file fails, you get an additional warning anyway. some cosmetic changes: - put the default loglevel into the builtin config file, so the code for the builtin fallback config is more similar to the one for the file config - added try/finally and changed name to "f" for same reason
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 23 Jan 2013 01:39:41 +0100
parents 881d9053592a
children 51ea4cb7b390
line wrap: on
line diff
--- a/MoinMoin/log.py	Mon Jan 21 17:47:31 2013 +0100
+++ b/MoinMoin/log.py	Wed Jan 23 01:39:41 2013 +0100
@@ -58,10 +58,11 @@
 # See http://www.python.org/doc/lib/logging-config-fileformat.html
 # We just use stderr output by default, if you want anything else,
 # you will have to configure logging.
-logging_defaults = {
-    'loglevel': 'INFO',
 logging_config = """\
+# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
@@ -138,13 +139,16 @@
     if not configured:
         # load builtin fallback logging config
         from StringIO import StringIO
-        config_file = StringIO(logging_config)
-        logging.config.fileConfig(config_file, logging_defaults)
+        f = StringIO(logging_config)
+        try:
+            logging.config.fileConfig(f)
+        finally:
+            f.close()
         configured = True
         l = getLogger(__name__)
         if err_msg:
             l.warning('load_config for "%s" failed with "%s".' % (conf_fname, err_msg))
-        l.warning('using logging configuration read from built-in fallback in MoinMoin.log module!')
+        l.info('using logging configuration read from built-in fallback in MoinMoin.log module')
         warnings.showwarning = _log_warning