本文整理汇总了Python中logging.NOTSET属性的典型用法代码示例。如果您正苦于以下问题:Python logging.NOTSET属性的具体用法?Python logging.NOTSET怎么用?Python logging.NOTSET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类logging
的用法示例。
在下文中一共展示了logging.NOTSET属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_level
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def set_level(self, level):
"""
Set the minimum level of messages to be logged.
Level of Log Messages
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0
@param level: minimum level of messages to be logged
@type level: int or long
@return: None
@rtype: None
"""
assert level in self._levelNames
list_of_handlers = self._logger.handlers
for handler in list_of_handlers:
handler.setLevel(level)
示例2: set_level
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def set_level(self, level):
"""
Set the minimum level of messages to be logged.
Level of Log Messages
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0
@param level: minimum level of messages to be logged
@type level: int or long
@return: None
@rtype: None
"""
assert level in self._levelNames
list_of_handlers = self._logger.handlers
for handler in list_of_handlers:
handler.setLevel(level)
示例3: _handle_existing_loggers
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def _handle_existing_loggers(existing, child_loggers, disable_existing):
"""
When (re)configuring logging, handle loggers which were in the previous
configuration but are not in the new configuration. There's no point
deleting them as other threads may continue to hold references to them;
and by disabling them, you stop them doing any logging.
However, don't disable children of named loggers, as that's probably not
what was intended by the user. Also, allow existing loggers to NOT be
disabled if disable_existing is false.
"""
root = logging.root
for log in existing:
logger = root.manager.loggerDict[log]
if log in child_loggers:
logger.level = logging.NOTSET
logger.handlers = []
logger.propagate = True
else:
logger.disabled = disable_existing
示例4: create_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def create_logger(app):
"""Get the ``'flask.app'`` logger and configure it if needed.
When :attr:`~flask.Flask.debug` is enabled, set the logger level to
:data:`logging.DEBUG` if it is not set.
If there is no handler for the logger's effective level, add a
:class:`~logging.StreamHandler` for
:func:`~flask.logging.wsgi_errors_stream` with a basic format.
"""
logger = logging.getLogger('flask.app')
if app.debug and logger.level == logging.NOTSET:
logger.setLevel(logging.DEBUG)
if not has_level_handler(logger):
logger.addHandler(default_handler)
return logger
示例5: log
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def log(self, level, msg, *args, **kwargs):
"""Delegate a log call to the underlying logger.
The level here is determined by the echo
flag as well as that of the underlying logger, and
logger._log() is called directly.
"""
# inline the logic from isEnabledFor(),
# getEffectiveLevel(), to avoid overhead.
if self.logger.manager.disable >= level:
return
selected_level = self._echo_map[self.echo]
if selected_level == logging.NOTSET:
selected_level = self.logger.getEffectiveLevel()
if level >= selected_level:
self.logger._log(level, msg, args, **kwargs)
示例6: set_logging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def set_logging(self, level):
level_list= ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"]
if level in level_list:
if(level == "CRITICAL"):
logging.basicConfig(level=logging.CRITICAL)
if (level == "ERROR"):
logging.basicConfig(level=logging.ERROR)
if (level == "WARNING"):
logging.basicConfig(level=logging.WARNING)
if (level == "INFO"):
logging.basicConfig(level=logging.INFO)
if (level == "DEBUG"):
logging.basicConfig(level=logging.DEBUG)
if (level == "NOTSET"):
logging.basicConfig(level=logging.NOTSET)
else:
print ("set logging level failed ,the level is invalid.")
示例7: get_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def get_logger(initial_level=logging.INFO):
"""Gets the named logger"""
logger = logging.getLogger(LOGGER_NAME)
if logger.level == logging.NOTSET:
logger.setLevel(initial_level)
if not logger.hasHandlers():
console_handler = logging.StreamHandler()
console_handler.setLevel(initial_level)
format_string = '%(levelname)s: %(message)s'
formatter = logging.Formatter(format_string)
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
return logger
示例8: test_azure_process
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def test_azure_process(self):
"""Test the processing of an uncompressed Azure file."""
counts = {}
report_db = self.accessor
report_schema = report_db.report_schema
for table_name in self.report_tables:
table = getattr(report_schema, table_name)
with schema_context(self.schema):
count = table.objects.count()
counts[table_name] = count
logging.disable(logging.NOTSET) # We are currently disabling all logging below CRITICAL in masu/__init__.py
with self.assertLogs("masu.processor.azure.azure_report_processor", level="INFO") as logger:
self.processor.process()
self.assertIn("INFO:masu.processor.azure.azure_report_processor", logger.output[0])
self.assertIn("costreport_a243c6f2-199f-4074-9a2c-40e671cf1584.csv", logger.output[0])
for table_name in self.report_tables:
table = getattr(report_schema, table_name)
with schema_context(self.schema):
count = table.objects.count()
self.assertTrue(count > counts[table_name])
self.assertFalse(os.path.exists(self.test_report))
示例9: setLevel
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def setLevel(level):
"""Set logging level for the main logger."""
level = level.lower().strip()
imdbpyLogger.setLevel(LEVELS.get(level, logging.NOTSET))
imdbpyLogger.log(imdbpyLogger.level, 'set logging threshold to "%s"',
logging.getLevelName(imdbpyLogger.level))
#imdbpyLogger.setLevel(logging.DEBUG)
# It can be an idea to have a single function to log and warn:
#import warnings
#def log_and_warn(msg, args=None, logger=None, level=None):
# """Log the message and issue a warning."""
# if logger is None:
# logger = imdbpyLogger
# if level is None:
# level = logging.WARNING
# if args is None:
# args = ()
# #warnings.warn(msg % args, stacklevel=0)
# logger.log(level, msg % args)
示例10: init_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def init_logger(log_file=None, log_file_level=logging.NOTSET):
log_format = logging.Formatter("[%(asctime)s %(levelname)s] %(message)s")
logger = logging.getLogger()
logger.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
console_handler.setFormatter(log_format)
logger.handlers = [console_handler]
if log_file and log_file != '':
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(log_file_level)
file_handler.setFormatter(log_format)
logger.addHandler(file_handler)
return logger
示例11: test_adapt_logger__noop
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def test_adapt_logger__noop(self):
"""Test that adapt_logger returns a standard python logger from a NoOpLogger."""
noop_logger = _logger.NoOpLogger()
standard_logger = _logger.adapt_logger(noop_logger)
# adapt_logger knows about the loggers attached to this class.
self.assertIs(noop_logger.logger, standard_logger)
# Verify properties of the logger
self.assertIsInstance(standard_logger, logging.Logger)
self.assertEqual('optimizely.logger.NoOpLogger', standard_logger.name)
self.assertEqual(logging.NOTSET, standard_logger.level)
# Should have a single NullHandler (with a default formatter).
self.assertEqual(1, len(standard_logger.handlers))
handler = standard_logger.handlers[0]
self.assertIsInstance(handler, logging.NullHandler)
self.assertEqual(
'%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s:%(message)s', handler.formatter._fmt,
)
示例12: activate_logging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def activate_logging(loggin_level: str = "info"):
import logging
if loggin_level == "notset":
level = logging.NOTSET
elif loggin_level == "debug":
level = logging.DEBUG
elif loggin_level == "info":
level = logging.INFO
elif loggin_level == "warning":
level = logging.WARNING
elif loggin_level == "error":
level = logging.ERROR
elif loggin_level == "critical":
level = logging.CRITICAL
else:
raise ValueError(
"Invalid loggin level provided! "
+ "Allowed are 'notset', 'debug', 'info', 'warning', 'error', "
+ "and 'critical'!"
)
logging.basicConfig(format="%(levelname)s :: %(message)s", level=level)
示例13: reset_logging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def reset_logging():
"""Reset Logging"""
manager = logging.root.manager
manager.disabled = logging.NOTSET
airflow_loggers = [
logger for logger_name, logger in manager.loggerDict.items() if logger_name.startswith('airflow')
]
for logger in airflow_loggers: # pylint: disable=too-many-nested-blocks
if isinstance(logger, logging.Logger):
logger.setLevel(logging.NOTSET)
logger.propagate = True
logger.disabled = False
logger.filters.clear()
handlers = logger.handlers.copy()
for handler in handlers:
# Copied from `logging.shutdown`.
try:
handler.acquire()
handler.flush()
handler.close()
except (OSError, ValueError):
pass
finally:
handler.release()
logger.removeHandler(handler)
示例14: log_level_from_string
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def log_level_from_string(log_level_string):
"""Convert string representation of a log level into logging.XXX constant"""
if isinstance(log_level_string, str):
level = log_level_string.upper()
if level == 'CRITICAL':
return logging.CRITICAL
if level == 'ERROR':
return logging.ERROR
if level == 'WARNING':
return logging.WARNING
if level == 'INFO':
return logging.INFO
if level == 'DEBUG':
return logging.DEBUG
if level == 'NOTSET':
return logging.NOTSET
return logging.NOTSET
示例15: init_logger
# 需要导入模块: import logging [as 别名]
# 或者: from logging import NOTSET [as 别名]
def init_logger(log_file=None, log_file_level=logging.NOTSET):
if isinstance(log_file, Path):
log_file = str(log_file)
log_format = logging.Formatter("%(message)s")
logger = logging.getLogger()
logger.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
console_handler.setFormatter(log_format)
logger.handlers = [console_handler]
if log_file:
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(log_file_level)
file_handler.setFormatter(log_format)
logger.addHandler(file_handler)
return logger