本文整理汇总了Python中logging.FATAL属性的典型用法代码示例。如果您正苦于以下问题:Python logging.FATAL属性的具体用法?Python logging.FATAL怎么用?Python logging.FATAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类logging
的用法示例。
在下文中一共展示了logging.FATAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def __call__(self, parser, namespace, value, option_string=None):
if option_string in ('--verbose', '-v'):
value = logging.DEBUG
elif option_string in ('--quiet', '-q'):
value = logging.ERROR
else:
levels = {
'FATAL': logging.FATAL,
'ERROR': logging.ERROR,
'WARNING': logging.WARNING,
'INFO': logging.INFO,
'DEBUG': logging.DEBUG
}
value = levels[value]
set_logging_level(value)
# Public methods
示例2: test_nested_with_virtual_parent
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def test_nested_with_virtual_parent(self):
# Logging levels when some parent does not exist yet.
m = self.next_message
INF = logging.getLogger("INF")
GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
CHILD = logging.getLogger("INF.BADPARENT")
INF.setLevel(logging.INFO)
# These should log.
GRANDCHILD.log(logging.FATAL, m())
GRANDCHILD.info(m())
CHILD.log(logging.FATAL, m())
CHILD.info(m())
# These should not log.
GRANDCHILD.debug(m())
CHILD.debug(m())
self.assert_log_lines([
('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
('INF.BADPARENT.UNDEF', 'INFO', '2'),
('INF.BADPARENT', 'CRITICAL', '3'),
('INF.BADPARENT', 'INFO', '4'),
])
示例3: tlog
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def tlog(self, level, text, *args):
"""
记录文本日志信息,较高级别的日志(FATAL)会被收集到总控统一存储以备后续追查。
实际的文本日志组装和输出是由标准库\
`logging — Logging facility for Python <https://docs.python.org/2.7/library/logging.html>`_\ 提供的
:param int level: 日志级别,级别包括:DEBUG < INFO < WARNING < ERROR < CRITICAL
:param obj text: 要输出的文本信息,通过python字符串的%语法可以获得类似c语言printf的效果
:param args: 格式化字符串中占位符对应的变量值,如果变量是对象则打印成json
:returns: 无返回
:rtype: None
"""
logger = logging.getLogger(self._log_name)
texts, json_args = self._format_request(logger.getEffectiveLevel(), text, args)
if len(json_args) > 0:
logger.log(level, texts, *json_args)
else:
logger.log(level, texts)
示例4: fatal
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def fatal(self, text, *args):
"""
打印fatal日志
:param obj text: 要输出的文本信息,通过python字符串的%语法可以获得类似c语言printf的效果
:param args: 格式化字符串中占位符对应的变量值,如果变量是对象则打印成json
:returns: 无返回
:rtype: None
"""
logger = logging.getLogger(self._log_name)
texts, json_args = self._format_request(logger.getEffectiveLevel(), text, args)
if sys.exc_info()[0] is None:
ei = None
else:
ei = True
if len(json_args) > 0:
logger.log(logging.FATAL, texts, *json_args, exc_info=ei)
else:
logger.log(logging.FATAL, texts, exc_info=ei)
示例5: get_console_handler
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def get_console_handler(config):
if config.silent:
target_level = logging.FATAL
elif config.verbose:
target_level = logging.DEBUG
elif config.net_debug:
target_level = NETWORK
elif config.quiet:
target_level = logging.ERROR
else:
target_level = logging.INFO
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(target_level)
log_format = LOG_FORMAT if config.verbose else "%(message)s"
handler.setFormatter(logging.Formatter(log_format))
return handler
示例6: _get_log_level
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def _get_log_level(level):
"""
small static method to get logging level
:param str level: string of the level e.g. "INFO"
:returns logging.<LEVEL>: appropriate debug level
"""
# default to DEBUG
if level is None or level == "DEBUG":
return logging.DEBUG
level = level.upper()
# Make debugging configurable
if level == "INFO":
return logging.INFO
elif level == "WARNING":
return logging.WARNING
elif level == "CRITICAL":
return logging.CRITICAL
elif level == "ERROR":
return logging.ERROR
elif level == "FATAL":
return logging.FATAL
else:
raise Exception("UnknownLogLevelException: enter a valid log level")
示例7: set_stderrthreshold
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [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)))
示例8: log
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def log(self, level, msg, *args, **kwargs):
"""Logs a message at a cetain level substituting in the supplied arguments.
This method behaves differently in python and c++ modes.
Args:
level: int, the standard logging level at which to log the message.
msg: str, the text of the message to log.
*args: The arguments to substitute in the message.
**kwargs: The keyword arguments to substitute in the message.
"""
if level >= logging.FATAL:
# Add property to the LogRecord created by this logger.
# This will be used by the ABSLHandler to determine whether it should
# treat CRITICAL/FATAL logs as really FATAL.
extra = kwargs.setdefault('extra', {})
extra[_ABSL_LOG_FATAL] = True
super(ABSLLogger, self).log(level, msg, *args, **kwargs)
示例9: test_standard_to_absl
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [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('')
示例10: _late_addoptions
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def _late_addoptions(parser, logcfg):
"""Add options to control logger"""
parser.addini(
name='logger_logsdir',
help='base directory with log files for file loggers [basetemp]',
default=None,
)
group = parser.getgroup('logger')
group.addoption('--logger-logsdir',
help='pick you own logs directory instead of default '
'directory under session tmpdir')
if logcfg._enabled:
parser = _log_option_parser(logcfg._loggers)
group.addoption('--loggers',
default=parser(logcfg._log_option_default),
type=parser,
metavar='LOGGER,LOGGER.LEVEL,...',
help='comma delimited list of loggers optionally suffixed with level '
'preceded by a dot. Levels can be lower or uppercase, or numeric. '
'For example: "logger1,logger2.info,logger3.FATAL,logger4.25"')
示例11: main
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def main(self, argv):
"""Main method, callable from command line"""
log.setLevel(logging.FATAL)
usage_str = "usage: %prog [options]\n"
parser = OptionParser(usage=usage_str)
parser.add_option("-s", "--startDate", dest="startDate", metavar="<startDate>", help="Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time on or after this date.")
parser.add_option("-e", "--endDate", dest="endDate", metavar="<endDate>", help="Date string (e.g., 2011-12-15), if provided, will only run conversion on items with ordering time before this date.")
parser.add_option("-n", "--normalizeMixtures", dest="normalizeMixtures", action="store_true", help="If set, when find medication mixtures, will unravel / normalize into separate entries, one for each ingredient")
parser.add_option("-d", "--doseCountLimit", dest="doseCountLimit", help="Medication orders with a finite number of doses specified less than this limit will be labeled as different items than those without a number specified, or whose number is >= to this limit. Intended to distinguish things like IV single bolus / use vs. continuous infusions and standing medication orders")
(options, args) = parser.parse_args(argv[1:])
log.info("Starting: " + str.join(" ", argv))
timer = time.time()
conv_options = ConversionOptions()
conv_options.extract_parser_options(options)
self.convertAndUpload(conv_options)
timer = time.time() - timer
log.info("%.3f seconds to complete", timer)
示例12: test_print_timings_prints
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def test_print_timings_prints(self):
"""Test timing code and printing really prints a message
"""
buf = io.StringIO()
# Nothing should be logged yet
self.assertEqual(len(self.log_stream.getvalue()), 0)
log.initialize()
# Still, nothing should be logged yet
self.assertEqual(len(self.log_stream.getvalue()), 0)
with log.timed(level=logging.FATAL):
_ = 1 + 1
with stdout_redirector(buf):
log.print_timings()
# Something should be printed
self.assertNotEqual(len(buf.getvalue()), 0)
log.close()
# Something should be logged
self.assertNotEqual(len(self.log_stream.getvalue()), 0)
示例13: emit
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def emit(self, record: logging.LogRecord) -> None:
# Same try-except as in e.g. `logging.StreamHandler`.
try:
ref = getattr(record, 'k8s_ref')
type = (
"Debug" if record.levelno <= logging.DEBUG else
"Normal" if record.levelno <= logging.INFO else
"Warning" if record.levelno <= logging.WARNING else
"Error" if record.levelno <= logging.ERROR else
"Fatal" if record.levelno <= logging.FATAL else
logging.getLevelName(record.levelno).capitalize())
reason = 'Logging'
message = self.format(record)
posting.enqueue(
ref=ref,
type=type,
reason=reason,
message=message)
except Exception:
self.handleError(record)
示例14: __init__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def __init__(self, *args, **kwargs):
""" Constructor.
:Parameters:
- `*username` (`string`) - Salesforce username.
- `*password` (`string`) - Salesforce password.
- `*login_url` (`string`) - Salesforce login URL.
- `*client_id` (`string`) - Salesforce client ID.
- `*client_secret` (`string`) - Salesforce client secret.
- `\**kwargs` - kwargs (see below)
:Keyword Arguments:
* *protocol* (`string`) --
Protocol (future use)
* *proxies* (`dict`) --
A dict containing proxies to be used by `requests` module. Ex:
`{"https": "example.org:443"}`
Default: `None`
* *version* (`string`) --
SFDC API version to use e.g. '39.0'
"""
self.username = args[0]
self.password = args[1]
self.client_id = args[2]
self.client_secret = args[3]
self.protocol = kwargs.get('protocol')
self.proxies = kwargs.get('proxies')
self.instance_url = None
self.logger = logging.getLogger('sfdc_py')
self.logger.setLevel(logging.FATAL)
self.logger.addHandler(logging.StreamHandler())
self.client_api_version = None
self.client_kwargs = kwargs
self.session_id = None
self.chatter = chatter.Chatter(self)
self.jobs = jobs.Jobs(self)
self.wave = wave.Wave(self)
示例15: __init__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import FATAL [as 别名]
def __init__(self) -> None:
logging.Handler.__init__(self, level = logging.FATAL + 5) # disable logging