本文整理汇总了Python中syslog.openlog函数的典型用法代码示例。如果您正苦于以下问题:Python openlog函数的具体用法?Python openlog怎么用?Python openlog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了openlog函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: warning
def warning(*args):
msg = make_msg(args)
if sys.stderr.isatty():
logging.warning(msg)
syslog.openlog(ident, syslog.LOG_NDELAY, facility)
syslog.syslog(syslog.LOG_WARNING, msg)
syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py
示例2: get_logger
def get_logger():
global logger
global config
if logger: return logger
syslog.openlog(caller, syslog.LOG_PID, syslog.LOG_DAEMON)
logger = SyslogWrapper(config)
return logger
开发者ID:pombredanne,项目名称:simplenet,代码行数:7,代码来源:config.py
示例3: _log_syslog
def _log_syslog(self, prio):
if self.__ident:
syslog.openlog(ident=self.__ident, facility=self.__fac)
syslog.syslog(prio, self.__last_message)
syslog.closelog()
else:
syslog.syslog(prio | self.__fac, self.__last_message)
开发者ID:Cougar,项目名称:evalimine,代码行数:7,代码来源:evlog.py
示例4: syslog
def syslog(message, ident = "", priority = "info", facility = "syslog", options = []):
"""
Send a string to syslog and return that same string.
"""
priority = { "emerg":SYSLOG.LOG_EMERG, "alert":SYSLOG.LOG_ALERT,
"crit":SYSLOG.LOG_CRIT, "err":SYSLOG.LOG_ERR,
"warning":SYSLOG.LOG_WARNING, "notice":SYSLOG.LOG_NOTICE,
"info":SYSLOG.LOG_INFO, "debug":SYSLOG.LOG_DEBUG }.get(str(priority).lower(),0)
facility = { "kern":SYSLOG.LOG_KERN, "user":SYSLOG.LOG_USER,
"mail":SYSLOG.LOG_MAIL, "daemon":SYSLOG.LOG_DAEMON,
"auth":SYSLOG.LOG_AUTH, "lpr":SYSLOG.LOG_LPR,
"news":SYSLOG.LOG_NEWS, "uucp":SYSLOG.LOG_UUCP,
"cron":SYSLOG.LOG_CRON, "syslog":SYSLOG.LOG_SYSLOG,
"local0":SYSLOG.LOG_LOCAL0, "local1":SYSLOG.LOG_LOCAL1,
"local2":SYSLOG.LOG_LOCAL2, "local3":SYSLOG.LOG_LOCAL3,
"local4":SYSLOG.LOG_LOCAL4, "local5":SYSLOG.LOG_LOCAL5,
"local6":SYSLOG.LOG_LOCAL6, "local7":SYSLOG.LOG_LOCAL7 }.get(str(facility).lower(),0)
option = 0
for opt in options:
option += { "pid":SYSLOG.LOG_PID, "cons":SYSLOG.LOG_CONS, "ndelay":SYSLOG.LOG_NDELAY,
"nowait":SYSLOG.LOG_NOWAIT, "perror":SYSLOG.LOG_PERROR }.get(str(opt).lower(),0)
message = str(message)
ident = str(ident)
if not ident: ident = os.path.basename(sys.argv[0])
SYSLOG.openlog(ident = ident, logoption = option, facility = facility)
add = ""
for line in message.split("\n"):
if line:
SYSLOG.syslog(priority, add + line)
add = " "
SYSLOG.closelog()
return message
开发者ID:robertwbrandt,项目名称:common,代码行数:32,代码来源:brandt.py
示例5: log
def log(msg, level=syslog.LOG_NOTICE):
if USE_STDERR:
print >> sys.stderr, msg
else:
syslog.openlog( 'xs-activity-server', 0, syslog.LOG_USER )
syslog.syslog(level, msg)
syslog.closelog()
开发者ID:NROER,项目名称:xsce,代码行数:7,代码来源:__init__.py
示例6: daemonize
def daemonize(self):
"""Makeself a daemon process.
Double fork, close standard pipes, start a new session and
open logs.
"""
pid = os.fork()
if pid == 0: # first child
os.setsid()
pid = os.fork()
if pid == 0: # second child
# Can't chdir to root if we have relative paths to
# conffile and other modules
#os.chdir('/')
os.umask(0)
else:
os._exit(0)
else:
os._exit(0)
# close stdin, stdout and stderr ...
for fd in range(3):
try:
os.close(fd)
except OSError:
pass
# ... and replace them with /dev/null
os.open('/dev/null', os.O_RDWR)
os.dup(0)
os.dup(0)
syslog.openlog('hip-mgmt-iface',
syslog.LOG_PID | syslog.LOG_NDELAY,
syslog.LOG_DAEMON)
syslog.syslog('FirewallController started.')
开发者ID:surki,项目名称:hipl,代码行数:35,代码来源:FirewallController.py
示例7: main
def main():
"""Feed the snmp_xen MIB tree and start listening for snmp's passpersist"""
global pp
syslog.openlog(sys.argv[0], syslog.LOG_PID)
retry_timestamp = int(time.time())
retry_counter = MAX_RETRY
while retry_counter > 0:
try:
syslog.syslog(syslog.LOG_INFO, "Starting PostgreSQL Performance gathering...")
# Load helpers
pp = snmp.PassPersist(OID_BASE)
pp.start(update_data, POOLING_INTERVAL) # Should'nt return (except if updater thread has died)
except KeyboardInterrupt:
print "Exiting on user request."
sys.exit(0)
except IOError, e:
if e.errno == errno.EPIPE:
syslog.syslog(syslog.LOG_INFO, "Snmpd had close the pipe, exiting...")
sys.exit(0)
else:
syslog.syslog(syslog.LOG_WARNING, "Updater thread has died: IOError: %s" % (e))
except Exception, e:
syslog.syslog(syslog.LOG_WARNING, "Main thread has died: %s: %s" % (e.__class__.__name__, e))
开发者ID:omacchioni,项目名称:snmp_psql_performance,代码行数:27,代码来源:snmp_psql_performance.py
示例8: log_warning
def log_warning(msg, syslog_identifier, also_print_to_console=False):
syslog.openlog(syslog_identifier)
syslog.syslog(syslog.LOG_WARNING, msg)
syslog.closelog()
if also_print_to_console:
print msg
开发者ID:Azure,项目名称:sonic-utilities,代码行数:7,代码来源:mlnx.py
示例9: log_error
def log_error(msg, syslog_identifier, also_print_to_console=False):
syslog.openlog(syslog_identifier)
syslog.syslog(syslog.LOG_ERR, msg)
syslog.closelog()
if also_print_to_console:
print msg
开发者ID:Azure,项目名称:sonic-utilities,代码行数:7,代码来源:mlnx.py
示例10: open
def open(self, verbosity=syslog.LOG_NOTICE):
log_options = syslog.LOG_PID | syslog.LOG_CONS | syslog.LOG_NDELAY
if self.options.debug:
log_options |= syslog.LOG_PERROR
syslog.openlog("conreality", logoption=log_options, facility=syslog.LOG_DAEMON)
syslog.setlogmask(syslog.LOG_UPTO(verbosity))
return self
开发者ID:conreality,项目名称:conreality,代码行数:7,代码来源:driver.py
示例11: main
def main():
"""Feed the snmp_xen MIB tree and start listening for snmp's passpersist"""
global pp
global node
syslog.openlog(sys.argv[0],syslog.LOG_PID)
retry_timestamp=int(time.time())
retry_counter=MAX_RETRY
while retry_counter>0:
try:
syslog.syslog(syslog.LOG_INFO,"Starting Xen monitoring...")
# Load helpers
pp=snmp.PassPersist(OID_BASE)
node=cxm.node.Node(platform.node())
# Set statics data
pp.add_str('1.1.0',node.get_hostname())
pp.add_gau('1.2.0',int(node.metrics.get_host_nr_cpus()))
oid=pp.encode("Domain-0")
pp.add_str('1.9.1.' + oid,'Domain-0')
pp.add_int('1.9.2.' + oid,0)
pp.add_gau('1.9.4.' + oid,2) # Always 2 VPCU for Dom0 (TODO: ask the Xen-API)
pp.start(update_data,POOLING_INTERVAL) # Should'nt return (except if updater thread has died)
except IOError, e:
if e.errno == errno.EPIPE:
syslog.syslog(syslog.LOG_INFO,"Snmpd had close the pipe, exiting...")
sys.exit(0)
except Exception, e:
syslog.syslog(syslog.LOG_WARNING,"Main thread as died: %s" % (e))
开发者ID:maddingue,项目名称:cxm,代码行数:33,代码来源:snmp_xen.py
示例12: setUp
def setUp(self):
global config_path
global cwd
weewx.debug = 1
syslog.openlog('test_templates', syslog.LOG_CONS)
syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))
# Save and set the current working directory in case some service changes it.
if not cwd:
cwd = os.getcwd()
else:
os.chdir(cwd)
try :
self.config_dict = configobj.ConfigObj(config_path, file_error=True)
except IOError:
sys.stderr.write("Unable to open configuration file %s" % config_path)
# Reraise the exception (this will eventually cause the program to exit)
raise
except configobj.ConfigObjError:
sys.stderr.write("Error while parsing configuration file %s" % config_path)
raise
# Remove the old directory:
try:
test_html_dir = os.path.join(self.config_dict['WEEWX_ROOT'], self.config_dict['StdReport']['HTML_ROOT'])
shutil.rmtree(test_html_dir)
except OSError, e:
if os.path.exists(test_html_dir):
print >> sys.stderr, "\nUnable to remove old test directory %s", test_html_dir
print >> sys.stderr, "Reason:", e
print >> sys.stderr, "Aborting"
exit(1)
开发者ID:MLAB-project,项目名称:weewx,代码行数:35,代码来源:test_templates.py
示例13: error
def error(*args):
msg = make_msg(args)
if sys.stderr.isatty():
logging.error(msg)
syslog.openlog(ident, syslog.LOG_NDELAY, facility)
syslog.syslog(syslog.LOG_ERR, msg)
syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py
示例14: debug
def debug(*args):
msg = make_msg(args)
if sys.stderr.isatty():
logging.debug(msg)
syslog.openlog(ident, syslog.LOG_NDELAY, facility)
syslog.syslog(syslog.LOG_DEBUG, msg)
syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py
示例15: config
def config():
global conf
confFile = 'docker-covenant.yml'
if os.path.isfile(confFile):
with open(confFile, 'r') as f:
conf = yaml.safe_load(f)
if conf["debug"]:
print("configuration file: ", confFile)
else:
print("Config file ", confFile, " doesn't exist.")
sys.exit(1)
try:
if not conf["syslog_ident"]:
logident = "docker-covenant"
else:
logident = conf["syslog_ident"]
syslog.openlog(ident=logident)
if conf["debug"]:
print("syslog_ident ", logident)
except (NameError):
pass
try:
if conf["debug"]:
print("Docker daemon info:\n", client.info())
except (NameError):
pass
开发者ID:konstruktoid,项目名称:docker-covenant,代码行数:35,代码来源:docker-covenant.py
示例16: __init__
def __init__(self, **kwargs):
defaults = {
'STAGE_DIR': STAGE_DIR,
'PROD_DIR': PROD_DIR,
'BIND_PREFIX': BIND_PREFIX,
'LOCK_FILE': LOCK_FILE,
'STOP_UPDATE_FILE': STOP_UPDATE_FILE,
'LAST_RUN_FILE': LAST_RUN_FILE,
'STAGE_ONLY': False,
'NAMED_CHECKZONE_OPTS': NAMED_CHECKZONE_OPTS,
'CLOBBER_STAGE': False,
'PUSH_TO_PROD': False,
'BUILD_ZONES': True,
'PRESERVE_STAGE': False,
'LOG_SYSLOG': True,
'DEBUG': False,
'FORCE': False,
'bs': DNSBuildRun() # Build statistic
}
for k, default in defaults.iteritems():
setattr(self, k, kwargs.get(k, default))
# This is very specific to python 2.6
syslog.openlog('dnsbuild', 0, syslog.LOG_LOCAL6)
self.lock_fd = None
开发者ID:alecdhuse,项目名称:cyder,代码行数:25,代码来源:builder.py
示例17: run
def run(self):
syslog.openlog("vpnc-watch", syslog.LOG_PID, syslog.LOG_DAEMON)
pids = pidof(self.cmd)
if pids:
pids = ", ".join(map(str, pids))
raise Error, "%s already running (%s)" % (self.cmd, pids)
self.start()
self.detach()
try:
signal.signal(signal.SIGHUP, self.signal)
signal.signal(signal.SIGTERM, self.signal)
self.do_exit = False
while not self.do_exit:
self.do_restart = False
time.sleep(1)
running = self.isrunning()
if not running:
syslog.syslog(syslog.LOG_WARNING, "%s died" % self.name)
elif self.do_exit or self.do_restart:
self.stop()
if self.do_restart or not running:
self.start()
syslog.syslog(syslog.LOG_INFO, "exiting")
except Error, e:
syslog.syslog(syslog.LOG_ERR, "error: " + str(e))
sys.exit(1)
开发者ID:alex-vpn,项目名称:vpncwatch,代码行数:29,代码来源:vpnc-watch.py
示例18: main
def main():
global isy, programs, syslogUse, syslogFacility, logfile
# Setup syslog if requested
if syslogUse:
syslog.openlog(logoption=syslog.LOG_PID, facility=syslogFacilities[syslogFacility])
# Open logfile if requested
if logfile:
try:
logfile = open(logfile, 'ab+')
except IOError:
usage('ERROR: Failed to open logfile! %s' % sys.exc_info()[1])
# Dump status on sigusr1
signal.signal(signal.SIGUSR1,status_dump)
# Connect to ISY
try:
isy = Isy(addr=isyHost, userl=isyUser, userp=isyPass, debug=isyDebug)
except:
print "ERROR: Connection to ISY failed!"
sys.exit(1)
programs = get_proginfo(isy) # Get info about programs for trigger logging
server = ISYEvent()
server.subscribe(addr=isyHost, userl=isyUser, userp=isyPass, debug=isyDebug)
server.set_process_func(parse_event, "")
try:
#print('Use Control-C to exit')
server.events_loop() #no return
except KeyboardInterrupt:
print('Exiting')
开发者ID:sjthespian,项目名称:ISYlogger,代码行数:35,代码来源:ISYlogger.py
示例19: main
def main ():#funcion principal
logs = open("FilesOutput/CompleteTables_Logs_error.txt", 'w')#se abre archivo log
#abrimos syslog para registrar lo que realiza el script...
syslog.openlog("CompleteTables.py", syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO,"this script has created the next output files CompleteTables_Logs_error.txt")
information_DB = ReadCSV(sys.argv[1])#obtenemos la informacion de la base de datos...
syslog.syslog(syslog.LOG_INFO, "Completando datos en tablas no relacionadas")
#se generan las conexiones
data_connected_import = ConnectDB(information_DB['import'][0], information_DB['import'][1], information_DB['import'][2], information_DB['import'][3])
data_connected_export = ConnectDB(information_DB['export'][0], information_DB['export'][1], information_DB['export'][2], information_DB['export'][3])
#se realiza el mismo proceso para las diferentes tablas...
#insertando elementos tabla tipodispositivo
CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "tipo_dispositivo", "tipodispositivo", "tipo", "tipodispositivo_id_seq", 1)
#insertando elementos tabla marca
CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "marca", "marca", "marca", "marca_id_seq", 1)
#insertando elementos tabla tipousuario
CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "tipo_usuario", "tipousuario", "tipo", "tipousuario_id_seq", 0)
#insertando elementos tabla estadodispositivo and tabla estadousuario
CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "estado", "estadodispositivo", "descripcion", "estadodispositivo_id_seq", 1)
logs.write("ok")
logs.close()
syslog.closelog()#cerramos syslog
return 0
开发者ID:Dmedina11,项目名称:MigrateDB2,代码行数:31,代码来源:CompleteTables.py
示例20: main
def main(args):
''' Notify the user '''
try:
options, arguments = getopt.getopt(args[1:], 'f:')
except getopt.error:
sys.exit('Usage: neubot notifier [-f database]\n')
if arguments:
sys.exit('Usage: neubot notifier [-f database]\n')
database = '/var/neubot/database.sqlite3'
for name, value in options:
if name == '-f':
database = value
syslog.openlog('neubot_notify', syslog.LOG_PID, syslog.LOG_USER)
while True:
if __should_adjust_privacy(database):
__notify_adjust_privacy()
privacy_interval = SHORT_PRIVACY_INTERVAL
else:
privacy_interval = LONG_PRIVACY_INTERVAL
time.sleep(privacy_interval)
开发者ID:felipebusnello,项目名称:neubot,代码行数:26,代码来源:unix.py
注:本文中的syslog.openlog函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论