Python syslog 模块,LOG_ERR 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用syslog.LOG_ERR

项目:anytools    作者:ucookie    | 项目源码 | 文件源码
def confirm_leave(self, owner, level):
        """
        ??????owner,level???????facility,severity
        """
        # ?????
        facility = syslog.LOG_USER
        severity = syslog.LOG_INFO
        # as??????syslog????
        level_info = dict(INFO=syslog.LOG_INFO, WARN=syslog.LOG_WARNING,
                          ERROR=syslog.LOG_ERR, DEBUG=syslog.LOG_DEBUG)

        if level in level_info.keys():
            severity = level_info[level]

        # ????
        if owner in ['ecms_troubleshoot']:
            severity = syslog.syslog.LOG_EMERG

        return facility, severity
项目:glog-cli    作者:globocom    | 项目源码 | 文件源码
def test_format_colored_with_level_error(self):
        self.message.level = syslog.LOG_ERR
        log = TailFormatter('({source}) - {message}', color=True).format(self.message)
        self.assertEquals(colored('(dummy.source) - dummy message', 'red'), log)
项目:glog-cli    作者:globocom    | 项目源码 | 文件源码
def test_get_log_level_from_code(self):
        self.assertEquals('CRITICAL', LogLevel.find_by_syslog_code(syslog.LOG_CRIT)['name'])
        self.assertEquals('WARNING', LogLevel.find_by_syslog_code(syslog.LOG_WARNING)['name'])
        self.assertEquals('DEBUG', LogLevel.find_by_syslog_code(syslog.LOG_DEBUG)['name'])
        self.assertEquals('INFO', LogLevel.find_by_syslog_code(syslog.LOG_INFO)['name'])
        self.assertEquals('ERROR', LogLevel.find_by_syslog_code(syslog.LOG_ERR)['name'])
        self.assertEquals('NOTICE', LogLevel.find_by_syslog_code(syslog.LOG_NOTICE)['name'])
        self.assertEquals('', LogLevel.find_by_syslog_code(9999)['name'])
项目:glog-cli    作者:globocom    | 项目源码 | 文件源码
def test_get_log_level_code(self):
        self.assertEquals(syslog.LOG_CRIT, LogLevel.find_by_level_name('CRITICAL'))
        self.assertEquals(syslog.LOG_WARNING, LogLevel.find_by_level_name('WARNING'))
        self.assertEquals(syslog.LOG_DEBUG, LogLevel.find_by_level_name('DEBUG'))
        self.assertEquals(syslog.LOG_INFO, LogLevel.find_by_level_name('INFO'))
        self.assertEquals(syslog.LOG_ERR, LogLevel.find_by_level_name('ERROR'))
        self.assertEquals(syslog.LOG_NOTICE, LogLevel.find_by_level_name('NOTICE'))
        self.assertIsNone(LogLevel.find_by_level_name('UNKNOWN'))
项目:weewx-influx    作者:matthewwall    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)

# some unit labels are rather lengthy.  this reduces them to something shorter.
项目:weewx-interceptor    作者:matthewwall    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
项目:axel    作者:craigcabrey    | 项目源码 | 文件源码
def handle_finished_download():
    torrent_id = os.environ['TR_TORRENT_ID']
    syslog.syslog('Beginning processing of torrent {0}'.format(torrent_id))

    transmission_client = transmissionrpc.Client(
        transmission_host, port=transmission_port, user=transmission_user,
        password=transmission_password
    )
    torrent = transmission_client.get_torrent(torrent_id)

    # Make sure transmission called us with a completed torrent
    if torrent.progress != 100.0:
        syslog.syslog(syslog.LOG_ERR, 'Called with an incomplete torrent')
        sys.exit(1)

    if couchpotato_category in torrent.downloadDir:
        if not ignore_couchpotato:
            handle_couchpotato(torrent)
    elif sonarr_category in torrent.downloadDir:
        if not ignore_sonarr:
            handle_sonarr(torrent)
    else:
        handle_manual(torrent)

    # Immediately remove torrents that are not whitelisted (by tracker)
    if not whitelisted(torrent):
        transmission_client.remove_torrent(torrent_id)
        pb_notify('Removed non-whitelisted torrent {0}'.format(torrent.name))
项目:weewx-sdr    作者:matthewwall    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
项目:wifi-observer    作者:realmar    | 项目源码 | 文件源码
def commit(db_conn):
    try:
        db_conn.commit()
    except sqlite3.Error as e:
        print('sql error: ' + e.args[0])
        syslog(LOG_ERR, 'sql error: ' + e.args[0])
        raise e
项目:wifi-observer    作者:realmar    | 项目源码 | 文件源码
def executeSQL(db_conn, sql_string, add_information={}):
    c = db_conn.cursor()

    try:
        entries = c.execute(sql_string)
        add_information['id'] = c.lastrowid
    except sqlite3.Error as e:
        print('sql error: ' + e.args[0])
        syslog(LOG_ERR, 'sql error: ' + e.args[0])
        raise e

    return entries
项目:weewx-highcharts    作者:gjr80    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
项目:weewx-highcharts    作者:gjr80    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
项目:Supercloud-core    作者:zhiming-shen    | 项目源码 | 文件源码
def log_err(err):
    print >>sys.stderr, err
    syslog.syslog(syslog.LOG_USER | syslog.LOG_ERR, "%s: %s" % (sys.argv[0], err))
项目:Supercloud-core    作者:zhiming-shen    | 项目源码 | 文件源码
def witter(foo):
    if log_details:
        syslog.syslog(syslog.LOG_USER | syslog.LOG_ERR, foo)
    print >>sys.stderr, foo
项目:weewx-wh23xx    作者:matthewwall    | 项目源码 | 文件源码
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)
项目:python-logbook-systemd    作者:vivienm    | 项目源码 | 文件源码
def test_levels(journal, logger):
    """Mapping between log levels and Syslog priorities."""
    with JournalHandler().threadbound():
        logger.critical('Critical message')
        assert journal['PRIORITY'] == str(syslog.LOG_CRIT)
        logger.error('Error message')
        assert journal['PRIORITY'] == str(syslog.LOG_ERR)
        logger.warning('Warning message')
        assert journal['PRIORITY'] == str(syslog.LOG_WARNING)
        logger.notice('Notice message')
        assert journal['PRIORITY'] == str(syslog.LOG_NOTICE)
        logger.info('Info message')
        assert journal['PRIORITY'] == str(syslog.LOG_INFO)
        logger.debug('Debug message')
        assert journal['PRIORITY'] == str(syslog.LOG_DEBUG)
项目:axel    作者:craigcabrey    | 项目源码 | 文件源码
def handle_manual(torrent):
    auto_processed = False

    def handle_media(path, move):
        nonlocal auto_processed

        guess = guessit.guessit(path)

        if guess['type'] == 'episode':
            move_episode(path, guess, move)
            auto_processed = True
        elif guess['type'] == 'movie':
            move_movie(path, guess, move)
            auto_processed = True

    part_regex = re.compile('.*part(\d+).rar', re.IGNORECASE)
    for index, file in torrent.files().items():
        file_path = os.path.join(torrent.downloadDir, file['name'])
        if check_extension(file_path) and 'sample' not in file_path.lower():
            # Log and ignore mkv files of less than ~92MiB
            try:
                if os.path.getsize(file_path) >= 96811278:
                    handle_media(file_path, False)
                else:
                    syslog.syslog(
                        syslog.LOG_ERR, 'Detected false media file, skipping'
                    )
            except FileNotFoundError:
                syslog.syslog(syslog.LOG_ERR, 'Torrent file missing, skipping')
        elif file_path.endswith('rar'):
            # Ignore parts beyond the first in a rar series
            match = part_regex.match(file_path)
            if match and int(match.group(1)) > 1:
                continue

            with tempfile.TemporaryDirectory() as temp_dir:
                paths = extract(file_path, temp_dir)

                if paths:
                    for path in paths:
                        shutil.chown(path, group=plex_group)
                        os.chmod(path, 0o664)

                        handle_media(path, True)

    if auto_processed:
        pb_notify(
            textwrap.dedent(
                '''
                    Manually added torrent {0} finished downloading
                    and was auto-processed
                '''.format(torrent.name)
            ).strip()
        )
    else:
        pb_notify(
            'Manually added torrent {0} finished downloading'.format(
                torrent.name
            )
        )