示例#1
0
 def test_notice(self):
     logger = FakeLogger()
     a = log._LogAdapter(logger, 'testserver')
     a.notice('testnotice')
     self.assertEqual(logger.log_calls, [(
         log.NOTICE, 'testnotice', (),
         {'extra': {'txn': None, 'server': 'testserver'}})])
示例#2
0
文件: test_log.py 项目: ahale/brim
 def test_notice(self):
     logger = FakeLogger()
     a = log._LogAdapter(logger, "testserver")
     a.notice("testnotice")
     self.assertEquals(
         logger.log_calls, [(log.NOTICE, "testnotice", (), {"extra": {"txn": None, "server": "testserver"}})]
     )
示例#3
0
 def test_exception(self):
     logger = FakeLogger()
     a = log._LogAdapter(logger, 'testserver')
     a.exception('testexc')
     self.assertEqual(logger.error_calls, [(
         ("testexc None ['None']",),
         {'extra': {'txn': None, 'server': 'testserver'}})])
     try:
         raise Exception('blah')
     except Exception:
         a.exception('testexc2')
     self.assertEqual(len(logger.error_calls), 2)
     self.assertEqual(
         logger.error_calls[-1][1],
         {'extra': {'txn': None, 'server': 'testserver'}})
     self.assertTrue(logger.error_calls[-1][0][0].startswith(
         'testexc2 Exception: blah [\'Traceback (most recent call '
         'last):\', \'  File '))
     self.assertTrue(logger.error_calls[-1][0][0].endswith(
         ', in test_exception\', "    raise Exception(\'blah\')", '
         '\'Exception: blah\']'))
示例#4
0
文件: test_log.py 项目: ahale/brim
 def test_exception(self):
     logger = FakeLogger()
     a = log._LogAdapter(logger, "testserver")
     a.exception("testexc")
     self.assertEquals(
         logger.error_calls, [(("testexc None ['None']",), {"extra": {"txn": None, "server": "testserver"}})]
     )
     try:
         raise Exception("blah")
     except Exception:
         a.exception("testexc2")
     self.assertEquals(len(logger.error_calls), 2)
     self.assertEquals(logger.error_calls[-1][1], {"extra": {"txn": None, "server": "testserver"}})
     self.assertTrue(
         logger.error_calls[-1][0][0].startswith(
             "testexc2 Exception: blah ['Traceback (most recent call " "last):', '  File "
         )
     )
     self.assertTrue(
         logger.error_calls[-1][0][0].endswith(
             ", in test_exception', \"    raise Exception('blah')\", " "'Exception: blah']"
         )
     )
示例#5
0
文件: test_log.py 项目: ahale/brim
 def test_effective_level(self):
     a = log._LogAdapter(FakeLogger(), "testserver")
     self.assertEquals(a.getEffectiveLevel(), DEBUG)
示例#6
0
文件: test_log.py 项目: ahale/brim
 def test_process(self):
     a = log._LogAdapter(None, "testserver")
     a.txn = "abc"
     self.assertEquals(a.process("test", {}), ("test", {"extra": {"txn": "abc", "server": "testserver"}}))
示例#7
0
 def test_process(self):
     a = log._LogAdapter(None, 'testserver')
     a.txn = 'abc'
     self.assertEqual(
         a.process('test', {}),
         ('test', {'extra': {'txn': 'abc', 'server': 'testserver'}}))