Пример #1
0
 def get_log_level():
     try:
         level = conf.getint('log', 'level')
         if level is None: level = 0
     except ValueError:
         level = logging.__dict__.get(conf.get('log', 'level'), 0)
     return level
Пример #2
0
default_format = logging.Formatter(u"%(name)s: %(levelname)s: %(message)s")

try:
    from amoco import conf

    def get_log_level():
        try:
            level = conf.getint('log', 'level')
            if level is None: level = 0
        except ValueError:
            level = logging.__dict__.get(conf.get('log', 'level'), 0)
        return level

    default_level = get_log_level()
    if conf.has_option('log', 'file'):
        logfilename = conf.get('log', 'file')
    elif conf.getboolean('log', 'tempfile'):
        import tempfile
        logfilename = tempfile.mkstemp('.log', prefix="amoco-")[1]
    else:
        logfilename = None
except ImportError:
    default_level = logging.ERROR
    logfilename = None

if logfilename:
    logfile = logging.FileHandler(logfilename, mode='w')
    logfile.setFormatter(default_format)
    logfile.setLevel(logging.DEBUG)
    conf.set('log', 'file', logfilename)
else:
Пример #3
0
import logging

VERBOSE = 15
logging.addLevelName(VERBOSE, 'VERBOSE')
#logging.captureWarnings(True)

default_format = logging.Formatter("%(name)s: %(levelname)s: %(message)s")

try:
    from amoco import conf
    try:
        default_level = conf.getint('log', 'level')
        if default_level is None: default_level = 0
    except ValueError:
        default_level = logging._levelNames.get(conf.get('log', 'level'), 0)
    if conf.has_option('log', 'file'):
        logfilename = conf.get('log', 'file')
    else:
        logfilename = None
except ImportError:
    default_level = logging.ERROR
    logfilename = None

if logfilename:
    logfile = logging.FileHandler(logfilename, mode='w')
    logfile.setFormatter(default_format)
    logfile.setLevel(logging.DEBUG)
else:
    logfile = None