def start_syslog(name='python-app', facility=syslog.LOG_DAEMON, capture_stdout=IfNotInteractive, capture_stderr=IfNotInteractive):
if syslog is Null:
raise RuntimeError("syslog is not available on this platform")
for handler in root_logger.handlers[:]:
root_logger.removeHandler(handler)
handler = SyslogHandler(name, facility)
handler.setFormatter(_default_formatter)
root_logger.addHandler(handler)
if capture_stdout:
sys.stdout = StandardIOLogger(root_logger.info)
if capture_stderr:
sys.stderr = StandardIOLogger(root_logger.error)
评论列表
文章目录