changeset 2151:9ea845c1c826

EmailHandler get log level
author Ana Balica <ana.balica@gmail.com>
date Mon, 15 Jul 2013 11:27:33 +0300
parents 48b752c4609c
children e6e4b8bcab11
files MoinMoin/log.py
diffstat 1 files changed, 1 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/log.py	Mon Jul 15 11:15:10 2013 +0300
+++ b/MoinMoin/log.py	Mon Jul 15 11:27:33 2013 +0300
@@ -178,37 +178,6 @@
     return logger
 
 
-def get_log_level(section_name, conf_fname=None):
-    """ Get from the config the log level of a section
-
-    :param conf_name: configuration filename path
-    :return: handler log level
-    """
-    conf_fname = os.environ.get('MOINLOGGINGCONF', conf_fname)
-    got_config = False
-    if conf_fname:
-        try:
-            conf_fname = os.path.abspath(conf_fname)
-            f = open(conf_fname)
-            got_config = True
-        except IOError as e:
-            logger = getLogger(__name__)
-            logger.warning('load_config for "{0}" failed with "{1}".'.format(conf_fname, str(e)))
-    if not got_config:
-        from StringIO import StringIO
-        f = StringIO(logging_config)
-
-    import ConfigParser
-    cp = ConfigParser.ConfigParser()
-    if hasattr(f, 'readline'):
-        cp.readfp(f)
-    else:
-        cp.read(f)
-    f.close()
-    if cp.has_option(section_name, 'level'):
-        return cp.get(section_name, 'level')
-
-
 class EmailHandler(logging.Handler):
     """ A custom handler class which sends email for each logging event using
     wiki mail configuration
@@ -236,7 +205,7 @@
         # the app config is accessible after logging is initialized, so set the
         # arguments and make the decision to send mail or not here
         toaddrs = self.toaddrs if self.toaddrs else cfg.admin_emails
-        log_level = get_log_level('handler_email')
+        log_level = logging.getLevelName(self.level)
         subject = self.subject if self.subject else '[{0}][{1}] Log message'.format(
             cfg.sitename, log_level)
         msg = self.format(record)