ana-balica committed 9ea845c

EmailHandler get log level

Comments (0)

Files changed (1)

     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:
-    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
         # 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.