本文整理汇总了Python中absl.logging.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Python logging.ERROR属性的具体用法?Python logging.ERROR怎么用?Python logging.ERROR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类absl.logging
的用法示例。
在下文中一共展示了logging.ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_stderrthreshold
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [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)))
示例2: test_standard_to_absl
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [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('')
示例3: test_get_initial_for_level
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_get_initial_for_level(self):
self.assertEqual('F', converter.get_initial_for_level(logging.CRITICAL))
self.assertEqual('E', converter.get_initial_for_level(logging.ERROR))
self.assertEqual('W', converter.get_initial_for_level(logging.WARNING))
self.assertEqual('I', converter.get_initial_for_level(logging.INFO))
self.assertEqual('I', converter.get_initial_for_level(logging.DEBUG))
self.assertEqual('I', converter.get_initial_for_level(logging.NOTSET))
self.assertEqual('F', converter.get_initial_for_level(51))
self.assertEqual('E', converter.get_initial_for_level(49))
self.assertEqual('E', converter.get_initial_for_level(41))
self.assertEqual('W', converter.get_initial_for_level(39))
self.assertEqual('W', converter.get_initial_for_level(31))
self.assertEqual('I', converter.get_initial_for_level(29))
self.assertEqual('I', converter.get_initial_for_level(21))
self.assertEqual('I', converter.get_initial_for_level(19))
self.assertEqual('I', converter.get_initial_for_level(11))
self.assertEqual('I', converter.get_initial_for_level(9))
self.assertEqual('I', converter.get_initial_for_level(1))
self.assertEqual('I', converter.get_initial_for_level(-1))
示例4: logging_level_verbosity
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [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)))
示例5: get_v1_distribution_strategy
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def get_v1_distribution_strategy(params):
"""Returns the distribution strategy to use."""
if params["use_tpu"]:
# Some of the networking libraries are quite chatty.
for name in ["googleapiclient.discovery", "googleapiclient.discovery_cache",
"oauth2client.transport"]:
logging.getLogger(name).setLevel(logging.ERROR)
tpu_cluster_resolver = tf.distribute.cluster_resolver.TPUClusterResolver(
tpu=params["tpu"],
zone=params["tpu_zone"],
project=params["tpu_gcp_project"],
coordinator_name="coordinator"
)
logging.info("Issuing reset command to TPU to ensure a clean state.")
tf.Session.reset(tpu_cluster_resolver.get_master())
# Estimator looks at the master it connects to for MonitoredTrainingSession
# by reading the `TF_CONFIG` environment variable, and the coordinator
# is used by StreamingFilesDataset.
tf_config_env = {
"session_master": tpu_cluster_resolver.get_master(),
"eval_session_master": tpu_cluster_resolver.get_master(),
"coordinator": tpu_cluster_resolver.cluster_spec()
.as_dict()["coordinator"]
}
os.environ["TF_CONFIG"] = json.dumps(tf_config_env)
distribution = tf.distribute.experimental.TPUStrategy(
tpu_cluster_resolver, steps_per_run=100)
else:
distribution = distribution_utils.get_distribution_strategy(
num_gpus=params["num_gpus"])
return distribution
示例6: set_tf_log_level
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [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}"
示例7: error
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def error(msg, *args, **kwargs):
"""Logs an error message."""
log(ERROR, msg, *args, **kwargs)
示例8: log
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [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)
示例9: get_absl_log_prefix
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def get_absl_log_prefix(record):
"""Returns the absl log prefix for the log record.
Args:
record: logging.LogRecord, the record to get prefix for.
"""
created_tuple = time.localtime(record.created)
created_microsecond = int(record.created % 1.0 * 1e6)
critical_prefix = ''
level = record.levelno
if _is_non_absl_fatal_record(record):
# When the level is FATAL, but not logged from absl, lower the level so
# it's treated as ERROR.
level = logging.ERROR
critical_prefix = _CRITICAL_PREFIX
severity = converter.get_initial_for_level(level)
return '%c%02d%02d %02d:%02d:%02d.%06d %5d %s:%d] %s' % (
severity,
created_tuple.tm_mon,
created_tuple.tm_mday,
created_tuple.tm_hour,
created_tuple.tm_min,
created_tuple.tm_sec,
created_microsecond,
_get_thread_id(),
record.filename,
record.lineno,
critical_prefix)
示例10: test_py_logging_verbosity_file
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_py_logging_verbosity_file(self, verbosity):
"""Tests -v/--verbosity flag with Python logging to stderr."""
v_flag = '-v=%d' % verbosity
self._exec_test(
_verify_ok,
[['stderr', None, ''],
# When using python logging, it only creates a file named INFO,
# unlike C++ it also creates WARNING and ERROR files.
['absl_log_file', 'INFO', self._get_logs(verbosity)]],
use_absl_log_file=True,
extra_args=[v_flag])
示例11: test_error
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_error(self):
with mock.patch.object(self.logger, 'log'):
self.logger.error(self.message)
self.logger.log.assert_called_once_with(std_logging.ERROR, self.message)
示例12: test_logging_levels
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_logging_levels(self):
old_level = logging.get_verbosity()
logging.set_verbosity(logging.DEBUG)
self.assertEquals(logging.get_verbosity(), logging.DEBUG)
self.assertTrue(logging.level_debug())
self.assertTrue(logging.level_info())
self.assertTrue(logging.level_warning())
self.assertTrue(logging.level_error())
logging.set_verbosity(logging.INFO)
self.assertEquals(logging.get_verbosity(), logging.INFO)
self.assertFalse(logging.level_debug())
self.assertTrue(logging.level_info())
self.assertTrue(logging.level_warning())
self.assertTrue(logging.level_error())
logging.set_verbosity(logging.WARNING)
self.assertEquals(logging.get_verbosity(), logging.WARNING)
self.assertFalse(logging.level_debug())
self.assertFalse(logging.level_info())
self.assertTrue(logging.level_warning())
self.assertTrue(logging.level_error())
logging.set_verbosity(logging.ERROR)
self.assertEquals(logging.get_verbosity(), logging.ERROR)
self.assertFalse(logging.level_debug())
self.assertFalse(logging.level_info())
self.assertTrue(logging.level_error())
logging.set_verbosity(old_level)
示例13: test_absl_to_cpp
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_absl_to_cpp(self):
self.assertEqual(0, converter.absl_to_cpp(absl_logging.DEBUG))
self.assertEqual(0, converter.absl_to_cpp(absl_logging.INFO))
self.assertEqual(1, converter.absl_to_cpp(absl_logging.WARN))
self.assertEqual(2, converter.absl_to_cpp(absl_logging.ERROR))
self.assertEqual(3, converter.absl_to_cpp(absl_logging.FATAL))
with self.assertRaises(TypeError):
converter.absl_to_cpp('')
示例14: test_standard_to_cpp
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_standard_to_cpp(self):
self.assertEqual(0, converter.standard_to_cpp(logging.DEBUG))
self.assertEqual(0, converter.standard_to_cpp(logging.INFO))
self.assertEqual(1, converter.standard_to_cpp(logging.WARN))
self.assertEqual(1, converter.standard_to_cpp(logging.WARNING))
self.assertEqual(2, converter.standard_to_cpp(logging.ERROR))
self.assertEqual(3, converter.standard_to_cpp(logging.FATAL))
self.assertEqual(3, converter.standard_to_cpp(logging.CRITICAL))
with self.assertRaises(TypeError):
converter.standard_to_cpp('')
示例15: test_string_to_standard
# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import ERROR [as 别名]
def test_string_to_standard(self):
self.assertEqual(logging.DEBUG, converter.string_to_standard('debug'))
self.assertEqual(logging.INFO, converter.string_to_standard('info'))
self.assertEqual(logging.WARNING, converter.string_to_standard('warn'))
self.assertEqual(logging.WARNING, converter.string_to_standard('warning'))
self.assertEqual(logging.ERROR, converter.string_to_standard('error'))
self.assertEqual(logging.CRITICAL, converter.string_to_standard('fatal'))
self.assertEqual(logging.DEBUG, converter.string_to_standard('DEBUG'))
self.assertEqual(logging.INFO, converter.string_to_standard('INFO'))
self.assertEqual(logging.WARNING, converter.string_to_standard('WARN'))
self.assertEqual(logging.WARNING, converter.string_to_standard('WARNING'))
self.assertEqual(logging.ERROR, converter.string_to_standard('ERROR'))
self.assertEqual(logging.CRITICAL, converter.string_to_standard('FATAL'))