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


Python LogOptions.log_dir方法代码示例

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


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

示例1: init

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
def init(filebase):
  """
    Set up default logging using:
      {--log_dir}/filebase.{INFO,WARNING,...}
  """
  logging._acquireLock()

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

  # clear existing handlers
  teardown_stderr_logging()
  teardown_disk_logging()

  # setup INFO...FATAL handlers
  num_disk_handlers = 0
  for handler in _setup_disk_logging(filebase):
    root_logger.addHandler(handler)
    _DISK_LOGGERS.append(handler)
  for handler in _setup_stderr_logging():
    root_logger.addHandler(handler)
    _STDERR_LOGGERS.append(handler)

  logging._releaseLock()

  if len(_DISK_LOGGERS) > 0 and LogOptions.stderr_log_level() != LogOptions.LOG_LEVEL_NONE:
    print('Writing log files to disk in %s' % LogOptions.log_dir(), file=sys.stderr)

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

示例2: _cmdline

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
    def _cmdline(self):
        host_sandbox = None
        if os.environ.get("MESOS_DIRECTORY"):
            host_sandbox = os.path.join(os.environ.get("MESOS_DIRECTORY"), "sandbox")

        params = dict(
            log_dir=LogOptions.log_dir(),
            log_to_disk="DEBUG",
            checkpoint_root=self._checkpoint_root,
            sandbox=host_sandbox or self._root,
            task_id=self._task_id,
            thermos_json=self._task_filename,
            hostname=self._hostname,
            process_logger_mode=self._process_logger_mode,
            rotate_log_size_mb=self._rotate_log_size_mb,
            rotate_log_backups=self._rotate_log_backups,
        )

        if getpass.getuser() == "root" and self._role:
            params.update(setuid=self._role)

        cmdline_args = [sys.executable, self._runner_pex]
        cmdline_args.extend("--%s=%s" % (flag, value) for flag, value in params.items() if value is not None)
        if self._enable_chroot:
            cmdline_args.extend(["--enable_chroot"])
        for name, port in self._ports.items():
            cmdline_args.extend(["--port=%s:%s" % (name, port)])
        return cmdline_args
开发者ID:mohammadsamir,项目名称:aurora,代码行数:30,代码来源:thermos_task_runner.py

示例3: _cmdline

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
  def _cmdline(self):
    host_sandbox = None
    if os.environ.get('MESOS_DIRECTORY'):
      host_sandbox = os.path.join(os.environ.get('MESOS_DIRECTORY'), 'sandbox')

    params = dict(log_dir=LogOptions.log_dir(),
                  log_to_disk='DEBUG',
                  checkpoint_root=self._checkpoint_root,
                  sandbox=host_sandbox or self._root,
                  task_id=self._task_id,
                  thermos_json=self._task_filename,
                  hostname=self._hostname,
                  process_logger_destination=self._process_logger_destination,
                  process_logger_mode=self._process_logger_mode,
                  rotate_log_size_mb=self._rotate_log_size_mb,
                  rotate_log_backups=self._rotate_log_backups)

    if getpass.getuser() == 'root' and self._role:
      params.update(setuid=self._role)

    cmdline_args = [sys.executable, self._runner_pex]
    cmdline_args.extend(
        '--%s=%s' % (flag, value) for flag, value in params.items() if value is not None)
    if self._enable_chroot:
      cmdline_args.extend(['--enable_chroot'])
    if self._preserve_env:
      cmdline_args.extend(['--preserve_env'])
    if self._sandbox.is_filesystem_image:
      cmdline_args.extend(
          ['--mesos_containerizer_path=%s' % self._mesos_containerizer_path])
    for name, port in self._ports.items():
      cmdline_args.extend(['--port=%s:%s' % (name, port)])
    return cmdline_args
开发者ID:AltanAlpay,项目名称:aurora,代码行数:35,代码来源:thermos_task_runner.py

示例4: _cmdline

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
    def _cmdline(self):
        params = dict(
            log_dir=LogOptions.log_dir(),
            log_to_disk="DEBUG",
            checkpoint_root=self._checkpoint_root,
            sandbox=self._sandbox.root,
            container_sandbox=self._sandbox.container_root,
            task_id=self._task_id,
            thermos_json=self._task_filename,
            hostname=self._hostname,
            process_logger_destination=self._process_logger_destination,
            process_logger_mode=self._process_logger_mode,
            rotate_log_size_mb=self._rotate_log_size_mb,
            rotate_log_backups=self._rotate_log_backups,
        )

        if getpass.getuser() == "root" and self._role:
            params.update(setuid=self._role)

        cmdline_args = [sys.executable, self._runner_pex]
        cmdline_args.extend("--%s=%s" % (flag, value) for flag, value in params.items() if value is not None)
        if self._enable_chroot:
            cmdline_args.extend(["--enable_chroot"])
        if self._preserve_env:
            cmdline_args.extend(["--preserve_env"])
        if self._sandbox.is_filesystem_image:
            cmdline_args.extend(["--mesos_containerizer_path=%s" % self._mesos_containerizer_path])
        for name, port in self._ports.items():
            cmdline_args.extend(["--port=%s:%s" % (name, port)])
        return cmdline_args
开发者ID:bmhatfield,项目名称:aurora,代码行数:32,代码来源:thermos_task_runner.py

示例5: _setup_aggregated_disk_logging

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
def _setup_aggregated_disk_logging(filebase):
  filename = os.path.join(LogOptions.log_dir(), filebase + '.log')
  formatter = ProxyFormatter(LogOptions.disk_log_scheme)
  file_handler = PreambleFileHandler(filename, formatter.preamble())
  file_handler.setFormatter(formatter)
  file_handler.addFilter(GenericFilter(lambda level: level >= LogOptions.disk_log_level()))
  return [file_handler]
开发者ID:BabyDuncan,项目名称:commons,代码行数:9,代码来源:initialize.py

示例6: init

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [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

示例7: _cmdline

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
  def _cmdline(self):
    params = dict(log_dir=LogOptions.log_dir(),
                  log_to_disk='DEBUG',
                  checkpoint_root=self._checkpoint_root,
                  sandbox=self._root,
                  task_id=self._task_id,
                  thermos_json=self._task_filename)

    if getpass.getuser() == 'root':
      params.update(setuid=self._role)

    cmdline_args = [self._runner_pex]
    cmdline_args.extend('--%s=%s' % (flag, value) for flag, value in params.items())
    if self._enable_chroot:
      cmdline_args.extend(['--enable_chroot'])
    for name, port in self._ports.items():
      cmdline_args.extend(['--port=%s:%s' % (name, port)])
    return cmdline_args
开发者ID:betepahos,项目名称:incubator-aurora,代码行数:20,代码来源:thermos_task_runner.py

示例8: _setup_disk_logging

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
def _setup_disk_logging(filebase):
  handlers = []
  logroot = LogOptions.log_dir()
  safe_mkdir(logroot)
  now = time.localtime()

  def gen_filter(level):
    return GenericFilter(
      lambda record_level: record_level == level and level >= LogOptions.disk_log_level())

  def gen_link_filename(filebase, level):
    return '%(filebase)s.%(level)s' % {
      'filebase': filebase,
      'level': level,
    }

  hostname = gethostname()
  username = getpass.getuser()
  pid = os.getpid()
  datestring = time.strftime('%Y%m%d-%H%M%S', time.localtime())
  def gen_verbose_filename(filebase, level):
    return '%(filebase)s.%(hostname)s.%(user)s.log.%(level)s.%(date)s.%(pid)s' % {
      'filebase': filebase,
      'hostname': hostname,
      'user': username,
      'level': level,
      'date': datestring,
      'pid': pid
    }

  for filter_type, filter_name in _FILTER_TYPES.items():
    formatter = ProxyFormatter(LogOptions.disk_log_scheme)
    filter = gen_filter(filter_type)
    full_filebase = os.path.join(logroot, filebase)
    logfile_link = gen_link_filename(full_filebase, filter_name)
    logfile_full = gen_verbose_filename(full_filebase, filter_name)
    file_handler = logging.FileHandler(logfile_full)
    file_handler.setFormatter(formatter)
    file_handler.addFilter(filter)
    handlers.append(file_handler)
    _safe_setup_link(logfile_link, logfile_full)
  return handlers
开发者ID:adamsxu,项目名称:commons,代码行数:44,代码来源:initialize.py

示例9: _cmdline

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
  def _cmdline(self):
    host_sandbox = None
    if os.environ.get('MESOS_DIRECTORY'):
      host_sandbox = os.path.join(os.environ.get('MESOS_DIRECTORY'), 'sandbox')

    params = dict(log_dir=LogOptions.log_dir(),
                  log_to_disk='DEBUG',
                  checkpoint_root=self._checkpoint_root,
                  sandbox=host_sandbox or self._root,
                  task_id=self._task_id,
                  thermos_json=self._task_filename,
                  hostname=self._hostname)

    if getpass.getuser() == 'root' and self._role:
      params.update(setuid=self._role)

    cmdline_args = [sys.executable, self._runner_pex]
    cmdline_args.extend('--%s=%s' % (flag, value) for flag, value in params.items())
    if self._enable_chroot:
      cmdline_args.extend(['--enable_chroot'])
    for name, port in self._ports.items():
      cmdline_args.extend(['--port=%s:%s' % (name, port)])
    return cmdline_args
开发者ID:caofangkun,项目名称:apache-aurora,代码行数:25,代码来源:thermos_task_runner.py

示例10: _initialize_disk_logging

# 需要导入模块: from twitter.common.log.options import LogOptions [as 别名]
# 或者: from twitter.common.log.options.LogOptions import log_dir [as 别名]
def _initialize_disk_logging():
  safe_mkdir(LogOptions.log_dir())
开发者ID:BabyDuncan,项目名称:commons,代码行数:4,代码来源:initialize.py


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