python类LOG_PID的实例源码

__init__.py 文件源码 项目:python-application 作者: AGProjects 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, name, facility=syslog.LOG_DAEMON):
        logging.Handler.__init__(self)
        syslog.openlog(name, syslog.LOG_PID, facility)
logging_handlers.py 文件源码 项目:logdevourer 作者: Korbank 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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])
rpki-torrent.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号