本文整理匯總了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')