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


Python LogOptions.set_stdout_log_level方法代码示例

本文整理汇总了Python中twitter.common.log.options.LogOptions.set_stdout_log_level方法的典型用法代码示例。如果您正苦于以下问题:Python LogOptions.set_stdout_log_level方法的具体用法?Python LogOptions.set_stdout_log_level怎么用?Python LogOptions.set_stdout_log_level使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twitter.common.log.options.LogOptions的用法示例。


在下文中一共展示了LogOptions.set_stdout_log_level方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import set_stdout_log_level [as 别名]
  def execute(self):
    def add_targets(dir, buildfile):
      try:
        self.targets.extend(Target.get(addr) for addr in Target.get_all_addresses(buildfile))
      except (TypeError, ImportError):
        error(dir, include_traceback=True)
      except (IOError, SyntaxError):
        error(dir)

    if self.options.recursive_directory:
      with self.check_errors('There was a problem scanning the '
                             'following directories for targets:') as error:
        for dir in self.options.recursive_directory:
          for buildfile in BuildFile.scan_buildfiles(self.root_dir, dir):
            add_targets(dir, buildfile)

    if self.options.target_directory:
      with self.check_errors("There was a problem loading targets "
                             "from the following directory's BUILD files") as error:
        for dir in self.options.target_directory:
          add_targets(dir, BuildFile(self.root_dir, dir))

    timer = None
    if self.options.time:
      class Timer(object):
        def now(self):
          return time.time()
        def log(self, message):
          print message
      timer = Timer()

    logger = None
    if self.options.log or self.options.log_level:
      from twitter.common.log import init
      from twitter.common.log.options import LogOptions
      LogOptions.set_stdout_log_level((self.options.log_level or 'info').upper())
      logdir = self.config.get('goals', 'logdir')
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
      init('goals')
      logger = log

    context = Context(self.config, self.options, self.targets, log=logger)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
        print 'Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown)
        print
        return Phase.execute(context, 'goals')

    return Phase.attempt(context, self.phases, timer=timer)
开发者ID:billwei,项目名称:commons,代码行数:58,代码来源:goal.py

示例2: print

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import set_stdout_log_level [as 别名]
    app.help()
  for (command, doc) in app.get_commands_and_docstrings():
    if args[0] == command:
      print('command %s:' % command)
      print(doc)
      app.quit(0)
  print('unknown command: %s' % args[0], file=sys.stderr)


def generate_usage():
  usage = """
thermos

commands:
"""

  for (command, doc) in app.get_commands_and_docstrings():
    usage += '    ' + '%-10s' % command + '\t' + doc.split('\n')[0].strip() + '\n'
  app.set_usage(usage)


LogOptions.set_disk_log_level('NONE')
LogOptions.set_stdout_log_level('INFO')
generate_usage()


proxy_main = app.main


proxy_main()
开发者ID:dominichamon,项目名称:incubator-aurora,代码行数:32,代码来源:thermos.py

示例3: print

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import set_stdout_log_level [as 别名]
        app.help()
    for (command, doc) in app.get_commands_and_docstrings():
        if args[0] == command:
            print("command %s:" % command)
            print(doc)
            app.quit(0)
    print("unknown command: %s" % args[0], file=sys.stderr)


def generate_usage():
    usage = """
thermos

commands:
"""

    for (command, doc) in app.get_commands_and_docstrings():
        usage += "    " + "%-10s" % command + "\t" + doc.split("\n")[0].strip() + "\n"
    app.set_usage(usage)


LogOptions.set_disk_log_level("NONE")
LogOptions.set_stdout_log_level("INFO")
generate_usage()


proxy_main = app.main


proxy_main()
开发者ID:sumanau7,项目名称:incubator-aurora,代码行数:32,代码来源:thermos.py


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