本文整理汇总了Python中logging.TRACE属性的典型用法代码示例。如果您正苦于以下问题:Python logging.TRACE属性的具体用法?Python logging.TRACE怎么用?Python logging.TRACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类logging
的用法示例。
在下文中一共展示了logging.TRACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_common_options
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def add_common_options(arg_parser, argv=None):
argv = argv or sys.argv
arg_parser.add_argument(
'-q', '--quiet', dest='log_level', action='store_const',
default=logging.INFO, const=logging.NOTICE, help='quiet logging')
arg_parser.add_argument(
'-v', '--verbose', dest='log_level', action='store_const',
default=logging.INFO, const=logging.DEBUG, help=(
'verbose logging'))
arg_parser.add_argument(
'--trace', dest='log_level', action='store_const',
default=logging.INFO, const=logging.TRACE, help=(
'very verbose logging'))
# arg_parser.add_argument(
# '-s', '--silent', dest='log_level', action='store_const',
# default=logging.INFO, const=logging.CRITICAL)
arg_parser.add_argument(
'--version', action='version',
version='brozzler %s - %s' % (
brozzler.__version__, os.path.basename(argv[0])))
示例2: format
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def format(self, record):
try:
msg = record.msg.split(':', 1)
if len(msg) == 2:
record.msg = '[%-12s]%s' % (msg[0], msg[1])
except:
pass
levelname = record.levelname
if record.levelno == logging.TRACE:
levelname = 'TRACE'
record.levelname = levelname
if self.use_color and levelname in COLORS:
levelname_color = (
COLOR_SEQ % (30 + COLORS[levelname]) + levelname + RESET_SEQ)
record.levelname = levelname_color
return logging.Formatter.format(self, record)
示例3: format
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def format(self, record):
colors = {
'CRITICAL': 'reverse_red',
'ERROR': 'red',
'WARNING': 'yellow',
'SUCCESS': 'green',
'INFO': 'cyan',
'DEBUG': 'bright_grey',
'TRACE': 'reverse_white',
}
color = colors.get(record.levelname, 'white')
if self.name:
return colored(record.levelname, color) + ': ' + self.name + ': ' + record.getMessage()
else:
return colored(record.levelname, color) + ': ' + record.getMessage()
###################################################################################################
示例4: monkeypatch_trace
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def monkeypatch_trace(self: logging.Logger, msg: str, *args, **kwargs) -> None:
"""
Log 'msg % args' with severity 'TRACE'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)
"""
if self.isEnabledFor(TRACE_LEVEL):
self._log(TRACE_LEVEL, msg, args, **kwargs)
示例5: _create_trace_loglevel
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def _create_trace_loglevel(logging):
"Add TRACE log level and Logger.trace() method."
logging.TRACE = 5
logging.addLevelName(logging.TRACE, "TRACE")
def _trace(logger, message, *args, **kwargs):
if logger.isEnabledFor(logging.TRACE):
logger._log(logging.TRACE, message, args, **kwargs)
logging.Logger.trace = _trace
示例6: _apply_loglevel_from_env
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def _apply_loglevel_from_env(logger, env='DWAVE_HYBRID_LOG_LEVEL'):
name = os.getenv(env) or os.getenv(env.upper()) or os.getenv(env.lower())
if not name:
return
levels = {'trace': logging.TRACE, 'debug': logging.DEBUG, 'info': logging.INFO,
'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL}
requested_level = levels.get(name.lower())
if requested_level:
logger.setLevel(requested_level)
示例7: __init__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def __init__(self, **runopts):
super(Runnable, self).__init__()
self.runopts = runopts
self.timers = defaultdict(list)
self.timeit = make_timeit(self.timers, prefix=self.name, loglevel=logging.TRACE)
self.counters = defaultdict(int)
self.count = make_count(self.counters, prefix=self.name, loglevel=logging.TRACE)
示例8: __init__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def __init__(self, name=None, loglevel=logging.TRACE):
super(trace, self).__init__(name, loglevel)
示例9: test_init
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def test_init(self):
self.assertTrue(hasattr(logging, 'TRACE'))
self.assertEqual(getattr(logging, 'TRACE'), 5)
logger = logging.getLogger(__name__)
self.assertTrue(callable(logger.trace))
示例10: trace
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def trace(self, msg, *args, **kwargs):
"""Set trace logging level
Args:
msg (str): The message to be logged.
"""
self.log(logging.TRACE, msg, *args, **kwargs)
示例11: _logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def _logger(self):
"""Return the logger. The default_args property is not available in init."""
logging.setLoggerClass(TraceLogger)
logger = logging.getLogger(self.logger_name)
logger.setLevel(logging.TRACE)
return logger
示例12: trace
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def trace(self, message, *args, **kwargs):
"""
Verbose Debug Logging - Trace
"""
if self.isEnabledFor(logging.TRACE):
self._log(logging.TRACE, message, args, **kwargs)
示例13: test_apprise_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def test_apprise_logger():
"""
API: Apprise() Logger
"""
# Ensure we're not running in a disabled state
logging.disable(logging.NOTSET)
# Set our log level
URLBase.logger.setLevel(logging.DEPRECATE + 1)
# Deprication will definitely not trigger
URLBase.logger.deprecate('test')
# Verbose Debugging is not on at this point
URLBase.logger.trace('test')
# Set both logging entries on
URLBase.logger.setLevel(logging.TRACE)
# Deprication will definitely trigger
URLBase.logger.deprecate('test')
# Verbose Debugging will activate
URLBase.logger.trace('test')
# Disable Logging
logging.disable(logging.CRITICAL)
示例14: add_logging_level
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def add_logging_level(levelName, levelNum, methodName = None):
""" Adds a new logging level to the `logging` module and the currently configured logging class.
`levelName` becomes an attribute of the `logging` module with the value `levelNum`.
`methodName` becomes a convenience method for both `logging` itself and the class returned by `logging.getLoggerClass()`
(usually just `logging.Logger`). If `methodName` is not specified, `levelName.lower()` is used.
To avoid accidental clobberings of existing attributes, this method will raise an `AttributeError` if the level name
is already an attribute of the `logging` module or if the method name is already present .
Example
-------
>>> add_logging_level('TRACE', logging.DEBUG - 5)
>>> logging.getLogger(__name__).setLevel("TRACE")
>>> logging.getLogger(__name__).trace('that worked')
>>> logging.trace('so did this')
>>> logging.TRACE
5
"""
if not methodName:
methodName = levelName.lower()
if hasattr(logging, levelName) or hasattr(logging, methodName) or hasattr(logging.getLoggerClass(), methodName):
return
def logForLevel(self, message, *args, **kwargs):
if self.isEnabledFor(levelNum):
self._log(levelNum, message, args, **kwargs)
def logToRoot(message, *args, **kwargs):
logging.log(levelNum, message, *args, **kwargs)
logging.addLevelName(levelNum, levelName)
setattr(logging, levelName, levelNum)
setattr(logging.getLoggerClass(), methodName, logForLevel)
setattr(logging, methodName, logToRoot)
示例15: __str__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import TRACE [as 别名]
def __str__(self):
return self.__repr__()
# monkey-patch log levels TRACE and NOTICE