本文整理汇总了Python中syslog.LOG_PID属性的典型用法代码示例。如果您正苦于以下问题:Python syslog.LOG_PID属性的具体用法?Python syslog.LOG_PID怎么用?Python syslog.LOG_PID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类syslog
的用法示例。
在下文中一共展示了syslog.LOG_PID属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: safe_open
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_PID [as 别名]
def safe_open(self):
try:
syslog.openlog(self.app, syslog.LOG_PID)
except Exception as e:
print(e)
示例2: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_PID [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)
示例3: writeLog
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_PID [as 别名]
def writeLog(msg):
"""Output a message to the console/Syslog depending on the host"""
if os.name == "posix":
syslog.openlog(logoption=syslog.LOG_PID,facility=syslog.LOG_MAIL)
syslog.syslog(msg)
else:
print msg
return
示例4: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_PID [as 别名]
def __init__(self, facility, options=syslog.LOG_PID):
syslog.openlog(logoption=options, facility=facility)
super().__init__()
示例5: __init__
# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_PID [as 别名]
def __init__(self, facility=None, log_pid=True, log_perror=False,
**kwargs):
"""
Initialize Syslog Object
"""
super(NotifySyslog, self).__init__(**kwargs)
if facility:
try:
self.facility = SYSLOG_FACILITY_MAP[facility]
except KeyError:
msg = 'An invalid syslog facility ' \
'({}) was specified.'.format(facility)
self.logger.warning(msg)
raise TypeError(msg)
else:
self.facility = \
SYSLOG_FACILITY_MAP[
self.template_tokens['facility']['default']]
# Logging Options
self.logoptions = 0
# Include PID with each message.
# This may not appear evident if using journalctl since the pid
# will always display itself; however it will appear visible
# for log_perror combinations
self.log_pid = log_pid
# Print to stderr as well.
self.log_perror = log_perror
if log_pid:
self.logoptions |= syslog.LOG_PID
if log_perror:
self.logoptions |= syslog.LOG_PERROR
# Initialize our loggig
syslog.openlog(
self.app_id, logoption=self.logoptions, facility=self.facility)
return