本文整理匯總了Python中celery.utils.log.LoggingProxy類的典型用法代碼示例。如果您正苦於以下問題:Python LoggingProxy類的具體用法?Python LoggingProxy怎麽用?Python LoggingProxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了LoggingProxy類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_logging_proxy_recurse_protection
def test_logging_proxy_recurse_protection(self):
logger = self.setup_logger(loglevel=logging.ERROR, logfile=None, root=False)
p = LoggingProxy(logger, loglevel=logging.ERROR)
p._thread.recurse_protection = True
try:
self.assertIsNone(p.write("FOOFO"))
finally:
p._thread.recurse_protection = False
示例2: test_logging_proxy
def test_logging_proxy(self):
logger = self.setup_logger(loglevel=logging.ERROR, logfile=None, root=False)
with wrap_logger(logger) as sio:
p = LoggingProxy(logger, loglevel=logging.ERROR)
p.close()
p.write("foo")
self.assertNotIn("foo", sio.getvalue())
p.closed = False
p.write("foo")
self.assertIn("foo", sio.getvalue())
lines = ["baz", "xuzzy"]
p.writelines(lines)
for line in lines:
self.assertIn(line, sio.getvalue())
p.flush()
p.close()
self.assertFalse(p.isatty())
self.assertIsNone(p.fileno())
示例3: test_logging_proxy
def test_logging_proxy(self):
logger = self.setup_logger(loglevel=logging.ERROR, logfile=None,
root=False)
with mock.wrap_logger(logger) as sio:
p = LoggingProxy(logger, loglevel=logging.ERROR)
p.close()
p.write('foo')
self.assertNotIn('foo', sio.getvalue())
p.closed = False
p.write('foo')
self.assertIn('foo', sio.getvalue())
lines = ['baz', 'xuzzy']
p.writelines(lines)
for line in lines:
self.assertIn(line, sio.getvalue())
p.flush()
p.close()
self.assertFalse(p.isatty())
with mock.stdouts() as (stdout, stderr):
with in_sighandler():
p.write('foo')
self.assertTrue(stderr.getvalue())