当前位置: 首页>>代码示例>>Python>>正文


Python syslog.openlog函数代码示例

本文整理汇总了Python中syslog.openlog函数的典型用法代码示例。如果您正苦于以下问题:Python openlog函数的具体用法?Python openlog怎么用?Python openlog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了openlog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的syslog.openlog函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。