本文整理汇总了Python中syslog.openlog方法的典型用法代码示例。如果您正苦于以下问题:Python syslog.openlog方法的具体用法?Python syslog.openlog怎么用?Python syslog.openlog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syslog
的用法示例。
在下文中一共展示了syslog.openlog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def main():
if len(sys.argv) > 2:
Fatal('usage: %s [containers.yaml]' % sys.argv[0])
if len(sys.argv) == 2:
with open(sys.argv[1], 'r') as fp:
config = yaml.load(fp)
else:
config = yaml.load(sys.stdin)
syslog.openlog(PROGNAME)
LogInfo('processing container manifest')
CheckVersion(config)
all_volumes = LoadVolumes(config.get('volumes', []))
user_containers = LoadUserContainers(config.get('containers', []),
all_volumes)
CheckGroupWideConflicts(user_containers)
if user_containers:
infra_containers = LoadInfraContainers(user_containers)
RunContainers(infra_containers + user_containers)
示例2: safe_open
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def safe_open(self):
try:
syslog.openlog(self.app, syslog.LOG_PID)
except Exception as e:
print(e)
示例3: SendNotice
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def SendNotice(Message):
try:
syslog.openlog("genmon")
syslog.syslog("%s" % Message)
syslog.closelog()
except Exception as e1:
log.error("Error: " + str(e1))
console.error("Error: " + str(e1))
#------------------- Command-line interface for gengpio ------------------------
示例4: log
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [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)
示例5: main
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def main():
config = get_config_port_ip()
list_live_ip(config)
for i in config.keys():
if arp(i) == config[i]:
continue
if arp(i) == 'none':
syslog.openlog( 'WARNING', 0, syslog.LOG_LOCAL7 )
syslog.syslog(syslog.LOG_ALERT, '%s %s IS NOT ACTIVE ' % (socket.gethostname(), i))
else:
syslog.openlog( 'WARNING', 0, syslog.LOG_LOCAL4 )
syslog.syslog(syslog.LOG_ALERT, '%s %s IS IN WRONG PORT %s AND SHOULD BE IN %s ' % (socket.gethostname(), i, arp(i),config[i] ))
示例6: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self, threshold, sid=None, encoding='UTF-8'):
import syslog
AbstractLogger.__init__(self, threshold)
if sid is None:
sid = 'syslog'
self.encoding = encoding
syslog.openlog(sid, syslog.LOG_PID)
示例7: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self, facility=None):
# Default values always get evaluated, for which reason we avoid
# using 'syslog' directly, which may not be available.
facility = facility if facility is not None else syslog.LOG_USER
# Do not use super() unless type(logging.Handler) is 'type'
# (i.e. >= Python 2.7).
if not syslog:
raise RuntimeError("Syslog not available on this platform")
logging.Handler.__init__(self)
binary_name = _get_binary_name()
syslog.openlog(binary_name, 0, facility)
示例8: test_syslog_binary_name
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def test_syslog_binary_name(self):
# There is no way to test the actual output written to the
# syslog (e.g. /var/log/syslog) to confirm binary_name value
# is actually present
syslog.openlog = mock.Mock()
handlers.OSSysLogHandler()
syslog.openlog.assert_called_with(handlers._get_binary_name(),
0, syslog.LOG_USER)
示例9: syslog_writer_before_all
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def syslog_writer_before_all(self, features):
import syslog
syslog.openlog("radish")
syslog.syslog("begin run {}".format(self.marker))
示例10: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self):
"""Initialize live parser"""
self.parser = None
self.parser_name = None
self.event_type = None
self.log_source = None
syslog.openlog(facility=syslog.LOG_DAEMON)
示例11: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self, config='/opt/LogESP/config/parser.conf'):
"""Initialize live parser"""
self.conf = config
self.threads = []
syslog.openlog(facility=syslog.LOG_DAEMON)
示例12: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self):
"""Initialize daemon core object"""
# Open our log facility:
syslog.openlog(facility=syslog.LOG_DAEMON)
示例13: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self):
"""Initialize sentry core"""
self.rule_types = {}
self.threads = {}
syslog.openlog(facility=syslog.LOG_DAEMON)
示例14: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self):
"""Initialize trigger engine"""
self.rlist = []
self.rules = []
self.newrules = []
self.threads = {}
syslog.openlog(facility=syslog.LOG_DAEMON)
示例15: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import openlog [as 别名]
def __init__(self, rule):
"""Initialize trigger object"""
self.rule = rule
self.tzone = TIME_ZONE
self.lasteventid = None
self.justfired = False
self.timeint = timedelta(minutes=self.rule.time_int)
syslog.openlog(facility=syslog.LOG_DAEMON)