Python syslog 模块,openlog() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用syslog.openlog()

项目:daiquiri    作者:jd    | 项目源码 | 文件源码
def __init__(self, program_name, 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
        if not syslog:
            raise RuntimeError("Syslog not available on this platform")
        super(SyslogHandler, self).__init__()
        syslog.openlog(program_name, 0, facility)
项目:TOR-Hidden-Service-Verification    作者:arrase    | 项目源码 | 文件源码
def __init__(self):
        syslog.openlog(facility=syslog.LOG_DAEMON)
项目:python-application    作者:AGProjects    | 项目源码 | 文件源码
def __init__(self, name, facility=syslog.LOG_DAEMON):
        logging.Handler.__init__(self)
        syslog.openlog(name, syslog.LOG_PID, facility)
项目:broadview-collector    作者:openstack    | 项目源码 | 文件源码
def __init__(self):
        syslog.openlog(ident="BroadView")
项目:megadld    作者:arrase    | 项目源码 | 文件源码
def __init__(self):
        syslog.openlog(facility=syslog.LOG_DAEMON)
项目:piwall-cvtools    作者:infinnovation    | 项目源码 | 文件源码
def __init__(self, root, title, text, func, *args, **kw):
        Trace.__init__(self, trace = 0)
        self.root = root
        self.title = title
        self.text = text
        self.func = func
        self.args = args
        self.kw = kw
        self.trace_1("OK Cancel dialog created\n")
        syslog.openlog("tkController", syslog.LOG_LOCAL0)
项目:sdic    作者:percolate    | 项目源码 | 文件源码
def main():
    args = docopt(__doc__,
                  version="sdic {}".format(VERSION))

    # Check that the given directory exists
    if not isdir(args['<directory>']):
        error("The folder {} does not exist".format(args['<directory>']))

    # Try to get the config of the servers we are gonna use
    servers = get_servers_from_config(args['<directory>'])

    # Check that we are not already running
    program_name = os.path.basename(sys.argv[0])
    lock = FileLock("/tmp/{}.lock".format(program_name))
    if lock.is_locked():
        error("{} is already running. Delete {} if it's a mistake.".format(
            program_name, lock.path))

    # Everything's ok, run the main program
    with lock:
        syslog.openlog('sdic')

        has_output = False
        if not args['<server>']:
            for server in servers:
                if launch_queries(args['<directory>'], server):
                    has_output = True
        else:
            for server in servers:
                if server['name'] == args['<server>']:
                    if launch_queries(args['<directory>'], server):
                        has_output = True
        if has_output:
            return 1

        syslog.closelog()
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def log(self, entry):
        """ This method will log information to the local syslog facility """
        if self.logging:
            syslog.openlog('ansible-%s' % self.module._name)
            syslog.syslog(syslog.LOG_NOTICE, entry)
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def _log_to_syslog(self, msg):
        if HAS_SYSLOG:
            module = 'ansible-%s' % self._name
            facility = getattr(syslog, self._syslog_facility, syslog.LOG_USER)
            syslog.openlog(str(module), 0, facility)
            syslog.syslog(syslog.LOG_INFO, msg)
项目:homemadescripts    作者:helioloureiro    | 项目源码 | 文件源码
def error(message):
    """Error handling for logs"""
    errormsg = u"ERROR: %s" % message
    debug(errormsg)
    syslog.openlog("StallNoMan")
    syslog.syslog(syslog.LOG_ERR, errormsg)
项目:homemadescripts    作者:helioloureiro    | 项目源码 | 文件源码
def log(message):
    """Syslog handling for logs"""
    infomsg = u"%s" % message
    debug(infomsg)
    syslog.openlog("StallNoMan")
    syslog.syslog(syslog.LOG_INFO, infomsg)
项目:logdevourer    作者:Korbank    | 项目源码 | 文件源码
def __init__(self, facility, process_name):
        super(SysLogHandler, self).__init__()
        if facility not in SysLogHandler._FACILITIES:
            raise ValueError("invalid syslog facility: %s" % (facility,))
        syslog.openlog(process_name, syslog.LOG_PID,
                       SysLogHandler._FACILITIES[facility])
项目:ansible-provider-docs    作者:alibaba    | 项目源码 | 文件源码
def _log_to_syslog(self, msg):
        if HAS_SYSLOG:
            module = 'ansible-%s' % self._name
            facility = getattr(syslog, self._syslog_facility, syslog.LOG_USER)
            syslog.openlog(str(module), 0, facility)
            syslog.syslog(syslog.LOG_INFO, msg)
项目:anytools    作者:ucookie    | 项目源码 | 文件源码
def push_log_to_server(self):
        """????"""
        try:
            # ???????? 128 * 1024 ???????????????????
            step = 127 * 1024
            for i in xrange(0, len(self.message), step):
                syslog.openlog("", 0, self.facility)
                syslog.syslog(self.severity, self.message[i:i + step])
        except BaseException:
            traceback.print_exc()
项目:homeassistant    作者:NAStools    | 项目源码 | 文件源码
def send_message(self, message="", **kwargs):
        """Send a message to a user."""
        import syslog

        title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)

        syslog.openlog(title, self._option, self._facility)
        syslog.syslog(self._priority, message)
        syslog.closelog()
项目:RPKI-toolkit    作者:pavel-odintsov    | 项目源码 | 文件源码
def main():
  try:
    syslog_flags = syslog.LOG_PID
    if os.isatty(sys.stderr.fileno()):
      syslog_flags |= syslog.LOG_PERROR
    syslog.openlog("rpki-torrent", syslog_flags)

    # If I seriously expected this script to get a lot of further use,
    # I might rewrite this using subparsers, but it'd be a bit tricky
    # as argparse doesn't support making the subparser argument
    # optional and transmission gives no sane way to provide arguments
    # when running a completion script.  So, for the moment, let's
    # just fix the bugs accidently introduced while converting the
    # universe to argparse without making any radical changes to the
    # program structure here, even if the result looks kind of klunky.

    parser = argparse.ArgumentParser(description = __doc__)
    parser.add_argument("-c", "--config",
                        help = "configuration file")
    parser.add_argument("action", choices = ("poll", "generate", "mirror"), nargs = "?",
                        help = "action to take")
    args = parser.parse_args()

    global cfg
    cfg = MyConfigParser()
    cfg.read(args.config or
             [os.path.join(dn, fn)
              for fn in ("rcynic.conf", "rpki.conf")
              for dn in ("/var/rcynic/etc", "/usr/local/etc", "/etc")])

    if cfg.act_as_generator:
      if args.action == "generate":
        generator_main()
      elif args.action == "mirror":
        mirror_main()
      else:
        raise UseTheSourceLuke
    else:
      if args.action is None and all(v in os.environ for v in tr_env_vars):
        torrent_completion_main()
      elif args.action == "poll":
        poll_main()
      else:
        raise UseTheSourceLuke

  except:
    for line in traceback.format_exc().splitlines():
      syslog.syslog(line)
    sys.exit(1)