當前位置: 首頁>>代碼示例>>Python>>正文


Python syslog.LOG_INFO屬性代碼示例

本文整理匯總了Python中syslog.LOG_INFO屬性的典型用法代碼示例。如果您正苦於以下問題:Python syslog.LOG_INFO屬性的具體用法?Python syslog.LOG_INFO怎麽用?Python syslog.LOG_INFO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在syslog的用法示例。


在下文中一共展示了syslog.LOG_INFO屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
        """
        Perform Syslog Notification
        """

        _pmap = {
            NotifyType.INFO: syslog.LOG_INFO,
            NotifyType.SUCCESS: syslog.LOG_NOTICE,
            NotifyType.FAILURE: syslog.LOG_CRIT,
            NotifyType.WARNING: syslog.LOG_WARNING,
        }

        # Always call throttle before any remote server i/o is made
        self.throttle()
        try:
            syslog.syslog(_pmap[notify_type], body)

        except KeyError:
            # An invalid notification type was specified
            self.logger.warning(
                'An invalid notification type '
                '({}) was specified.'.format(notify_type))
            return False

        return True 
開發者ID:caronc,項目名稱:apprise,代碼行數:27,代碼來源:NotifySyslog.py

示例2: LogInfo

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def LogInfo(msg):
    syslog.syslog(syslog.LOG_LOCAL3 | syslog.LOG_INFO, msg) 
開發者ID:googlearchive,項目名稱:container-agent,代碼行數:4,代碼來源:run_containers.py

示例3: log

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def log(program, function, msg, level="I", display=True):
    global LAST_SHOWN
    # open syslog
    syslog.openlog("system: %s %s:%s:" % (level, program, function))
    # set priority
    priority = syslog.LOG_INFO
    if level == "E":
        priority = syslog.LOG_ERR
    elif level == "W":
        priority = syslog.LOG_WARNING
    priority |= syslog.LOG_LOCAL4
    # write to syslog
    syslog.syslog(priority, msg)
    #
    # NOTE: showlog / showlog -f to check the logs
    #

    if display:
        program_display = " %s: " % program
        displayed = " "
        # If loglevel is anything else than I, add it to our tag
        if level != "I":
            displayed += "[%s] " % level
        displayed += utf8_str(msg)
        # print using FBInk (via cFFI)
        fbink.fbink_print(fbink.FBFD_AUTO, "%s\n%s" % (program_display, displayed), FBINK_CFG) 
開發者ID:barsanuphe,項目名稱:librariansync,代碼行數:28,代碼來源:kindle_logging.py

示例4: test_emitCustomFacility

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_emitCustomFacility(self):
        """
        L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the
        syslog priority, if that key is present in the event dictionary.
        """
        self.observer.emit({
                'message': ('hello, world',), 'isError': False, 'system': '-',
                'syslogFacility': stdsyslog.LOG_CRON})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_INFO | stdsyslog.LOG_CRON, '[-] hello, world')]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_syslog.py

示例5: test_emitCustomSystem

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_emitCustomSystem(self):
        """
        L{SyslogObserver.emit} uses the value of the C{'system'} key to prefix
        the logged message.
        """
        self.observer.emit({'message': ('hello, world',), 'isError': False,
            'system': 'nonDefaultSystem'})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_INFO, "[nonDefaultSystem] hello, world")]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_syslog.py

示例6: test_emitMessage

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_emitMessage(self):
        """
        L{SyslogObserver.emit} logs the value of the C{'message'} key of the
        event dictionary it is passed to the syslog.
        """
        self.observer.emit({
                'message': ('hello, world',), 'isError': False,
                'system': '-'})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_INFO, "[-] hello, world")]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_syslog.py

示例7: test_emitMultilineMessage

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_emitMultilineMessage(self):
        """
        Each line of a multiline message is emitted separately to the syslog.
        """
        self.observer.emit({
                'message': ('hello,\nworld',), 'isError': False,
                'system': '-'})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_INFO, '[-] hello,'),
             (stdsyslog.LOG_INFO, '[-] \tworld')]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_syslog.py

示例8: test_emitStripsTrailingEmptyLines

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_emitStripsTrailingEmptyLines(self):
        """
        Trailing empty lines of a multiline message are omitted from the
        messages sent to the syslog.
        """
        self.observer.emit({
                'message': ('hello,\nworld\n\n',), 'isError': False,
                'system': '-'})
        self.assertEqual(
            self.events,
            [(stdsyslog.LOG_INFO, '[-] hello,'),
             (stdsyslog.LOG_INFO, '[-] \tworld')]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:14,代碼來源:test_syslog.py

示例9: info

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def info(msg):
    syslog.syslog(syslog.LOG_INFO, _encode(msg)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:logging.py

示例10: loglevel_info

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def loglevel_info():
    loglevel(syslog.LOG_INFO) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:logging.py

示例11: test_unknown_severity

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_unknown_severity(self):
        alertlib.Alert('test message', severity=-4).send_to_logs()
        self.assertEqual([(syslog.LOG_INFO, 'test message')],
                         self.sent_to_syslog) 
開發者ID:Khan,項目名稱:alertlib,代碼行數:6,代碼來源:alertlib_test.py

示例12: __init__

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def __init__(self, message_dict={}):
        self.message_dict = dict(message_dict[utils.MESSAGE])
        self.timestamp = arrow.get(self.message_dict.get("timestamp", None))
        self.level = self.message_dict.get("level", syslog.LOG_INFO)
        self.message = self.message_dict.get(utils.MESSAGE, "") 
開發者ID:globocom,項目名稱:glog-cli,代碼行數:7,代碼來源:graylog_api.py

示例13: test_format_colored_with_level_info

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
def test_format_colored_with_level_info(self):
        self.message.level = syslog.LOG_INFO
        log = TailFormatter('({source}) - {message}', color=True).format(self.message)
        self.assertEquals(colored('(dummy.source) - dummy message', 'green'), log) 
開發者ID:globocom,項目名稱:glog-cli,代碼行數:6,代碼來源:test_formats.py

示例14: test_get_log_level_from_code

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
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']) 
開發者ID:globocom,項目名稱:glog-cli,代碼行數:10,代碼來源:test_formats.py

示例15: test_get_log_level_code

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_INFO [as 別名]
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')) 
開發者ID:globocom,項目名稱:glog-cli,代碼行數:10,代碼來源:test_formats.py


注:本文中的syslog.LOG_INFO屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。