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


Python LogOptions._is_scribe_logging_required方法代码示例

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


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

示例1: init

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import _is_scribe_logging_required [as 别名]
def init(filebase=None):
  """
    Sets up default stderr logging and, if filebase is supplied, sets up disk logging using:
      {--log_dir}/filebase.{INFO,WARNING,...}

    If '--log_simple' is specified, logs are written into a single file:
      {--log_dir}/filebase.log
  """
  logging._acquireLock()

  # set up permissive logger
  root_logger = logging.getLogger()
  root_logger.setLevel(logging.DEBUG)

  # clear existing handlers
  teardown_scribe_logging()
  teardown_stderr_logging()
  teardown_disk_logging()
  for handler in root_logger.handlers:
    root_logger.removeHandler(handler)

  # setup INFO...FATAL handlers
  if filebase:
    _initialize_disk_logging()
    initializer = _setup_aggregated_disk_logging if LogOptions.simple() else _setup_disk_logging
    for handler in initializer(filebase):
      root_logger.addHandler(handler)
      _DISK_LOGGERS.append(handler)

  if LogOptions._is_scribe_logging_required():
    try:
      for handler in _setup_scribe_logging():
        root_logger.addHandler(handler)
        _SCRIBE_LOGGERS.append(handler)
    except ScribeHandler.ScribeHandlerException as err:
      print_stderr(err)

  for handler in _setup_stderr_logging():
    root_logger.addHandler(handler)
    _STDERR_LOGGERS.append(handler)

  logging._releaseLock()

  if len(_DISK_LOGGERS) > 0:
    print_stderr('Writing log files to disk in %s' % LogOptions.log_dir())
  if len(_SCRIBE_LOGGERS) > 0:
    print_stderr('Sending log messages to scribe host=%s:%d category=%s'
          % (LogOptions.scribe_host(), LogOptions.scribe_port(), LogOptions.scribe_category()))

  return root_logger
开发者ID:BabyDuncan,项目名称:commons,代码行数:52,代码来源:initialize.py


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