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


Python logging.DEBUG属性代码示例

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


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

示例1: _log_level

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def _log_level():
    """Parser to set logging level and acquire software version/commit"""

    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter, add_help=False)

    #parser.add_argument('--version', action='version', version=get_version())

    modify_log_level = parser.add_mutually_exclusive_group()
    modify_log_level.add_argument('--debug', action='store_const',
        dest='log_level', const=logging.DEBUG, default=logging.INFO,
        help='Verbose logging of debug information.')
    modify_log_level.add_argument('--quiet', action='store_const',
        dest='log_level', const=logging.WARNING, default=logging.INFO,
        help='Minimal logging; warnings only).')

    return parser 
开发者ID:nanoporetech,项目名称:medaka,代码行数:19,代码来源:medaka.py

示例2: _update_logging_levels

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def _update_logging_levels(self):
    """Updates absl logging levels to the current verbosity."""
    if not _absl_logger:
      return

    if self._value <= converter.ABSL_DEBUG:
      standard_verbosity = converter.absl_to_standard(self._value)
    else:
      # --verbosity is set to higher than 1 for vlog.
      standard_verbosity = logging.DEBUG - (self._value - 1)

    # Also update root level when absl_handler is used.
    if _absl_handler in logging.root.handlers:
      # Make absl logger inherit from the root logger. absl logger might have
      # a non-NOTSET value if logging.set_verbosity() is called at import time.
      _absl_logger.setLevel(logging.NOTSET)
      logging.root.setLevel(standard_verbosity)
    else:
      _absl_logger.setLevel(standard_verbosity) 
开发者ID:abseil,项目名称:abseil-py,代码行数:21,代码来源:__init__.py

示例3: set_stderrthreshold

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def set_stderrthreshold(s):
  """Sets the stderr threshold to the value passed in.

  Args:
    s: str|int, valid strings values are case-insensitive 'debug',
        'info', 'warning', 'error', and 'fatal'; valid integer values are
        logging.DEBUG|INFO|WARNING|ERROR|FATAL.

  Raises:
      ValueError: Raised when s is an invalid value.
  """
  if s in converter.ABSL_LEVELS:
    FLAGS.stderrthreshold = converter.ABSL_LEVELS[s]
  elif isinstance(s, str) and s.upper() in converter.ABSL_NAMES:
    FLAGS.stderrthreshold = s
  else:
    raise ValueError(
        'set_stderrthreshold only accepts integer absl logging level '
        'from -3 to 1, or case-insensitive string values '
        "'debug', 'info', 'warning', 'error', and 'fatal'. "
        'But found "{}" ({}).'.format(s, type(s))) 
开发者ID:abseil,项目名称:abseil-py,代码行数:23,代码来源:__init__.py

示例4: vlog_is_on

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def vlog_is_on(level):
  """Checks if vlog is enabled for the given level in caller's source file.

  Args:
    level: int, the C++ verbose logging level at which to log the message,
        e.g. 1, 2, 3, 4... While absl level constants are also supported,
        callers should prefer level_debug|level_info|... calls for
        checking those.

  Returns:
    True if logging is turned on for that level.
  """

  if level > converter.ABSL_DEBUG:
    # Even though this function supports level that is greater than 1, users
    # should use logging.vlog instead for such cases.
    # Treat this as vlog, 1 is equivalent to DEBUG.
    standard_level = converter.STANDARD_DEBUG - (level - 1)
  else:
    if level < converter.ABSL_FATAL:
      level = converter.ABSL_FATAL
    standard_level = converter.absl_to_standard(level)
  return _absl_logger.isEnabledFor(standard_level) 
开发者ID:abseil,项目名称:abseil-py,代码行数:25,代码来源:__init__.py

示例5: test_absl_to_standard

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def test_absl_to_standard(self):
    self.assertEqual(
        logging.DEBUG, converter.absl_to_standard(absl_logging.DEBUG))
    self.assertEqual(
        logging.INFO, converter.absl_to_standard(absl_logging.INFO))
    self.assertEqual(
        logging.WARNING, converter.absl_to_standard(absl_logging.WARN))
    self.assertEqual(
        logging.WARN, converter.absl_to_standard(absl_logging.WARN))
    self.assertEqual(
        logging.ERROR, converter.absl_to_standard(absl_logging.ERROR))
    self.assertEqual(
        logging.FATAL, converter.absl_to_standard(absl_logging.FATAL))
    self.assertEqual(
        logging.CRITICAL, converter.absl_to_standard(absl_logging.FATAL))
    # vlog levels.
    self.assertEqual(9, converter.absl_to_standard(2))
    self.assertEqual(8, converter.absl_to_standard(3))

    with self.assertRaises(TypeError):
      converter.absl_to_standard('') 
开发者ID:abseil,项目名称:abseil-py,代码行数:23,代码来源:converter_test.py

示例6: test_standard_to_absl

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def test_standard_to_absl(self):
    self.assertEqual(
        absl_logging.DEBUG, converter.standard_to_absl(logging.DEBUG))
    self.assertEqual(
        absl_logging.INFO, converter.standard_to_absl(logging.INFO))
    self.assertEqual(
        absl_logging.WARN, converter.standard_to_absl(logging.WARN))
    self.assertEqual(
        absl_logging.WARN, converter.standard_to_absl(logging.WARNING))
    self.assertEqual(
        absl_logging.ERROR, converter.standard_to_absl(logging.ERROR))
    self.assertEqual(
        absl_logging.FATAL, converter.standard_to_absl(logging.FATAL))
    self.assertEqual(
        absl_logging.FATAL, converter.standard_to_absl(logging.CRITICAL))
    # vlog levels.
    self.assertEqual(2, converter.standard_to_absl(logging.DEBUG - 1))
    self.assertEqual(3, converter.standard_to_absl(logging.DEBUG - 2))

    with self.assertRaises(TypeError):
      converter.standard_to_absl('') 
开发者ID:abseil,项目名称:abseil-py,代码行数:23,代码来源:converter_test.py

示例7: logging_level_verbosity

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def logging_level_verbosity(logging_verbosity):
  """Converts logging_level into TensorFlow logging verbosity value.

  Args:
    logging_verbosity: String value representing logging level: 'DEBUG', 'INFO',
    'WARN', 'ERROR', 'FATAL'
  """
  name_to_level = {
      'FATAL': logging.FATAL,
      'ERROR': logging.ERROR,
      'WARN': logging.WARN,
      'INFO': logging.INFO,
      'DEBUG': logging.DEBUG
  }

  try:
    return name_to_level[logging_verbosity]
  except Exception as e:
    raise RuntimeError('Not supported logs verbosity (%s). Use one of %s.' %
                       (str(e), list(name_to_level))) 
开发者ID:tensorflow,项目名称:hub,代码行数:22,代码来源:retrain.py

示例8: StartTeeLogsToFile

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def StartTeeLogsToFile(
  program_name: str = None,
  log_dir: str = None,
  file_log_level: int = logging.DEBUG,
) -> None:
  """Log messages to file as well as stderr.

  Args:
    program_name: The name of the program.
    log_dir: The directory to log to.
    file_log_level: The minimum verbosity level to log to file to.

  Raises:
    FileNotFoundError: If the requested log_dir does not exist.
  """
  if not pathlib.Path(log_dir).is_dir():
    raise FileNotFoundError(f"Log directory not found: '{log_dir}'")
  old_verbosity = logging.get_verbosity()
  logging.set_verbosity(file_log_level)
  logging.set_stderrthreshold(old_verbosity)
  logging.get_absl_handler().start_logging_to_file(program_name, log_dir)
  # The Absl logging handler function start_logging_to_file() sets logtostderr
  # to False. Re-enable whatever value it was before the call.
  FLAGS.logtostderr = False 
开发者ID:ChrisCummins,项目名称:clgen,代码行数:26,代码来源:logutil.py

示例9: TeeLogsToFile

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def TeeLogsToFile(
  program_name: str = None,
  log_dir: str = None,
  file_log_level: int = logging.DEBUG,
):
  """Temporarily enable logging to file.

  Args:
    program_name: The name of the program.
    log_dir: The directory to log to.
    file_log_level: The minimum verbosity level to log to file to.
  """
  try:
    StartTeeLogsToFile(program_name, log_dir, file_log_level)
    yield
  finally:
    StopTeeLogsToFile() 
开发者ID:ChrisCummins,项目名称:clgen,代码行数:19,代码来源:logutil.py

示例10: set_tf_log_level

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def set_tf_log_level(ll):
    # 0     | DEBUG            | [Default] Print all messages
    # 1     | INFO             | Filter out INFO messages
    # 2     | WARNING          | Filter out INFO & WARNING messages
    # 3     | ERROR            | Filter out all messages
    import os

    TF_VERSION = get_version(tf)
    if TF_VERSION < 2:
        import tensorflow.compat.v1.logging as tf_logging
    else:
        from absl import logging as tf_logging
    tf_ll = tf_logging.WARN
    tf_cpp_ll = 1
    ll = ll.lower()
    if ll == "debug":
        tf_ll = tf_logging.DEBUG
        tf_cpp_ll = 0
    if ll == "info":
        tf_cpp_ll = 0
        tf_ll = tf_logging.INFO
    if ll == "error":
        tf_ll = tf_logging.ERROR
        tf_cpp_ll = 2
    tf_logging.set_verbosity(tf_ll)
    os.environ["TF_CPP_MIN_LOG_LEVEL"] = f"{tf_cpp_ll}" 
开发者ID:dpressel,项目名称:mead-baseline,代码行数:28,代码来源:layers.py

示例11: debug

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def debug(msg, *args, **kwargs):
  """Logs a debug message."""
  log(DEBUG, msg, *args, **kwargs) 
开发者ID:abseil,项目名称:abseil-py,代码行数:5,代码来源:__init__.py

示例12: log

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def log(level, msg, *args, **kwargs):
  """Logs 'msg % args' at absl logging level 'level'.

  If no args are given just print msg, ignoring any interpolation specifiers.

  Args:
    level: int, the absl logging level at which to log the message
        (logging.DEBUG|INFO|WARNING|ERROR|FATAL). While some C++ verbose logging
        level constants are also supported, callers should prefer explicit
        logging.vlog() calls for such purpose.

    msg: str, the message to be logged.
    *args: The args to be substituted into the msg.
    **kwargs: May contain exc_info to add exception traceback to message.
  """
  if level > converter.ABSL_DEBUG:
    # Even though this function supports level that is greater than 1, users
    # should use logging.vlog instead for such cases.
    # Treat this as vlog, 1 is equivalent to DEBUG.
    standard_level = converter.STANDARD_DEBUG - (level - 1)
  else:
    if level < converter.ABSL_FATAL:
      level = converter.ABSL_FATAL
    standard_level = converter.absl_to_standard(level)

  # Match standard logging's behavior. Before use_absl_handler() and
  # logging is configured, there is no handler attached on _absl_logger nor
  # logging.root. So logs go no where.
  if not logging.root.handlers:
    logging.basicConfig()

  _absl_logger.log(standard_level, msg, *args, **kwargs) 
开发者ID:abseil,项目名称:abseil-py,代码行数:34,代码来源:__init__.py

示例13: _get_logs

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def _get_logs(self,
                verbosity,
                include_info_prefix=True):
    logs = []
    if verbosity >= 3:
      logs.append(_PY_VLOG3_LOG_MESSAGE)
    if verbosity >= 2:
      logs.append(_PY_VLOG2_LOG_MESSAGE)
    if verbosity >= logging.DEBUG:
      logs.append(_PY_DEBUG_LOG_MESSAGE)

    if verbosity >= logging.INFO:
      if include_info_prefix:
        logs.append(_PY_INFO_LOG_MESSAGE)
      else:
        logs.append(_PY_INFO_LOG_MESSAGE_NOPREFIX)
    if verbosity >= logging.WARN:
      logs.append(_PY_WARNING_LOG_MESSAGE)
    if verbosity >= logging.ERROR:
      logs.append(_PY_ERROR_LOG_MESSAGE)

    expected_logs = ''.join(logs)
    if six.PY3:
      # In Python 3 class types are represented a bit differently
      expected_logs = expected_logs.replace(
          "<type 'exceptions.OSError'>", "<class 'OSError'>")
    return expected_logs 
开发者ID:abseil,项目名称:abseil-py,代码行数:29,代码来源:logging_functional_test.py

示例14: test_py_logging_noshowprefixforinfo_verbosity

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def test_py_logging_noshowprefixforinfo_verbosity(self):
    self._exec_test(
        _verify_ok,
        [['stderr', None, self._get_logs(logging.DEBUG)]],
        pass_logtostderr=True,
        show_info_prefix=0,
        use_absl_log_file=True,
        extra_args=['-v=1']) 
开发者ID:abseil,项目名称:abseil-py,代码行数:10,代码来源:logging_functional_test.py

示例15: test_constructor_with_level

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import DEBUG [as 别名]
def test_constructor_with_level(self):
    self.logger = logging.ABSLLogger('', std_logging.DEBUG)
    self.assertEqual(std_logging.DEBUG, self.logger.getEffectiveLevel()) 
开发者ID:abseil,项目名称:abseil-py,代码行数:5,代码来源:logging_test.py


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