本文整理汇总了Python中logging.Manager方法的典型用法代码示例。如果您正苦于以下问题:Python logging.Manager方法的具体用法?Python logging.Manager怎么用?Python logging.Manager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging
的用法示例。
在下文中一共展示了logging.Manager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resetLogging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def resetLogging():
""" Reset the handlers and loggers so that we
can rerun the tests starting from a blank slate.
"""
__pragma__("skip")
logging._handlerList = []
import weakref
logging._handlers = weakref.WeakValueDictionary()
logging.root = logging.RootLogger(logging.WARNING)
logging.Logger.root = logging.root
logging.Logger.manager = logging.Manager(logging.root)
logging.root.manager = logging.Logger.manager
__pragma__("noskip")
if __envir__.executor_name == __envir__.transpiler_name:
logging._resetLogging()
示例2: h_LoggerConnected
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def h_LoggerConnected(self, envelope):
self.asLogger = envelope.sender
# Dirty trick here to completely re-initialize logging in this
# process... something the standard Python logging interface does
# not allow via the API.
self.oldLoggerRoot = logging.root
logging.root = ThespianLogForwarder(self.asLogger, self.transport)
logging.Logger.root = logging.root
logging.Logger.manager = logging.Manager(logging.Logger.root)
# logging.getLogger('Thespian.Admin') \
# .info('ActorSystem Administrator startup @ %s', self.myAddress)
# Now that logging is started, Admin startup can be confirmed
self.transport.scheduleTransmit(None,
TransmitIntent(self.addrOfStarter, EndpointConnected(0))
.addCallback(onFailure=actorStartupFailed))
self._activate()
return True
示例3: test_manager_loggerclass
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def test_manager_loggerclass(self):
logged = []
class MyLogger(logging.Logger):
def _log(self, level, msg, args, exc_info=None, extra=None):
logged.append(msg)
man = logging.Manager(None)
self.assertRaises(TypeError, man.setLoggerClass, int)
man.setLoggerClass(MyLogger)
logger = man.getLogger('test')
logger.warning('should appear in logged')
logging.warning('should not appear in logged')
self.assertEqual(logged, ['should appear in logged'])
示例4: __init__
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def __init__(self, level):
super().__init__(level)
self.propagate = False
_RootLogger.manager = logging.Manager(self)
示例5: test_set_log_record_factory
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def test_set_log_record_factory(self):
man = logging.Manager(None)
expected = object()
man.setLogRecordFactory(expected)
self.assertEqual(man.logRecordFactory, expected)
示例6: logging_sandbox
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def logging_sandbox():
# Monkeypatch a replacement root logger, so that our changes to logging
# configuration don't persist outside of the test
root_logger = logging.RootLogger(logging.WARNING)
with mock.patch.object(logging, "root", root_logger):
with mock.patch.object(logging.Logger, "root", root_logger):
with mock.patch.object(
logging.Logger, "manager", logging.Manager(root_logger)
):
yield
示例7: _reset_logging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import Manager [as 别名]
def _reset_logging(self):
if hasattr(self, 'oldLoggerRoot'):
logging.root = self.oldLoggerRoot
logging.Logger.root = self.oldLoggerRoot
logging.Logger.manager = logging.Manager(logging.Logger.root)
delattr(self, 'oldLoggerRoot')