Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.log Namespace Reference

Functions

def _log_warning
def load_config
def getLogger

Variables

dictionary logging_defaults
string logging_config
 configured = False
 fallback_config = False

Function Documentation

def MoinMoin.log._log_warning (   message,
  category,
  filename,
  lineno,
  file = None,
  line = None 
) [private]

Definition at line 107 of file log.py.

00107 
00108 def _log_warning(message, category, filename, lineno, file=None, line=None):
00109     # for warnings, we just want to use the logging system, not stderr or other files
00110     msg = "%s:%s: %s: %s" % (filename, lineno, category.__name__, message)
00111     logger = getLogger(__name__)
00112     logger.warning(msg) # Note: the warning will look like coming from here,
00113                         # but msg contains info about where it really comes from
00114 

Here is the call graph for this function:

def MoinMoin.log.getLogger (   name)
wrapper around logging.getLogger, so we can do some more stuff:
    - preprocess logger name
    - patch loglevel constants into logger object, so it can be used
      instead of the logging module

Definition at line 143 of file log.py.

00143 
00144 def getLogger(name):
00145     """ wrapper around logging.getLogger, so we can do some more stuff:
00146         - preprocess logger name
00147         - patch loglevel constants into logger object, so it can be used
00148           instead of the logging module
00149     """
00150     if not configured:
00151         load_config()
00152     logger = logging.getLogger(name)
00153     for levelnumber, levelname in logging._levelNames.items():
00154         if isinstance(levelnumber, int): # that list has also the reverse mapping...
00155             setattr(logger, levelname, levelnumber)
00156     return logger
00157 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.log.load_config (   conf_fname = None)
load logging config from conffile 

Definition at line 115 of file log.py.

00115 
00116 def load_config(conf_fname=None):
00117     """ load logging config from conffile """
00118     global configured
00119     err_msg = None
00120     conf_fname = os.environ.get('MOINLOGGINGCONF', conf_fname)
00121     if conf_fname:
00122         try:
00123             conf_fname = os.path.abspath(conf_fname)
00124             logging.config.fileConfig(conf_fname)
00125             configured = True
00126             l = getLogger(__name__)
00127             l.info('using logging configuration read from "%s"' % conf_fname)
00128             warnings.showwarning = _log_warning
00129         except Exception, err: # XXX be more precise
00130             err_msg = str(err)
00131     if not configured:
00132         # load builtin fallback logging config
00133         from StringIO import StringIO
00134         config_file = StringIO(logging_config)
00135         logging.config.fileConfig(config_file, logging_defaults)
00136         configured = True
00137         l = getLogger(__name__)
00138         if err_msg:
00139             l.warning('load_config for "%s" failed with "%s".' % (conf_fname, err_msg))
00140         l.warning('using logging configuration read from built-in fallback in MoinMoin.log module!')
00141         warnings.showwarning = _log_warning
00142 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 95 of file log.py.

Definition at line 96 of file log.py.

Initial value:
00001 """\
00002 [loggers]
00003 keys=root
00004 
00005 [handlers]
00006 keys=stderr
00007 
00008 [formatters]
00009 keys=default
00010 
00011 [logger_root]
00012 level=%(loglevel)s
00013 handlers=stderr
00014 
00015 [handler_stderr]
00016 class=StreamHandler
00017 level=NOTSET
00018 formatter=default
00019 args=(sys.stderr, )
00020 
00021 [formatter_default]
00022 format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s
00023 datefmt=
00024 class=logging.Formatter
00025 """

Definition at line 64 of file log.py.

Initial value:
00001 {
00002     'loglevel': 'INFO',
00003 }

Definition at line 61 of file log.py.