コード例 #1
0
ファイル: __init__.py プロジェクト: vitstradal/smoker
def init(name='',
         level=logging.WARN,
         syslog=True,
         console=True,
         config_file=''):
    global lg

    if os.path.exists(config_file):
        logging.config.fileConfig(config_file, disable_existing_loggers=False)

    lg = logging.getLogger(name)
    lg.setLevel(level)

    if os.path.exists(config_file):
        if not console:
            disable_console_logging(lg)
        return lg

    if console:
        lg_console = LevelHandler()
        lg_console.setFormatter(
            logging.Formatter('%(levelname)s: %(message)s'))

        lg.addHandler(lg_console)

    if syslog:
        lg_syslog = logging.handlers.SysLogHandler(address='/dev/log')
        lg_syslog.setFormatter(
            logging.Formatter('%(name)-9s %(levelname)-8s %(message)s'))

        lg.addHandler(lg_syslog)

    return lg
コード例 #2
0
ファイル: __init__.py プロジェクト: caohhung/smoker
def init(name='', level=logging.WARN, syslog=True, console=True,
         config_file=''):
    global lg

    if os.path.exists(config_file):
        logging.config.fileConfig(config_file, disable_existing_loggers=False)

    lg = logging.getLogger(name)
    lg.setLevel(level)

    if os.path.exists(config_file):
        if not console:
            disable_console_logging(lg)
        return lg

    if console:
        lg_console = LevelHandler()
        lg_console.setFormatter(
            logging.Formatter('%(levelname)s: %(message)s'))

        lg.addHandler(lg_console)

    if syslog:
        lg_syslog = logging.handlers.SysLogHandler(address='/dev/log')
        lg_syslog.setFormatter(
            logging.Formatter('%(name)-9s %(levelname)-8s %(message)s'))

        lg.addHandler(lg_syslog)

    return lg
コード例 #3
0
def init(name='', level=logging.WARN, syslog=True, console=True):
    global lg

    lg = logging.getLogger(name)
    lg.setLevel(level)

    if console:
        lg_console = LevelHandler()
        lg_console.setFormatter(
            logging.Formatter('%(levelname)s: %(message)s'))

        lg.addHandler(lg_console)

    if syslog:
        lg_syslog = logging.handlers.SysLogHandler(address='/dev/log')
        lg_syslog.setFormatter(
            logging.Formatter('%(name)-9s %(levelname)-8s %(message)s'))

        lg.addHandler(lg_syslog)

    return lg