本文整理汇总了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
示例2: LogInfo
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_INFO [as 别名]
def LogInfo(msg):
syslog.syslog(syslog.LOG_LOCAL3 | syslog.LOG_INFO, msg)
示例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)
示例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')])
示例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")])
示例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")])
示例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')])
示例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')])
示例9: info
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_INFO [as 别名]
def info(msg):
syslog.syslog(syslog.LOG_INFO, _encode(msg))
示例10: loglevel_info
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_INFO [as 别名]
def loglevel_info():
loglevel(syslog.LOG_INFO)
示例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)
示例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, "")
示例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)
示例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'])
示例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'))