Example #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'}})])
Example #2
0
 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"}})]
     )
Example #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\']'))
Example #4
0
 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']"
         )
     )
Example #5
0
 def test_effective_level(self):
     a = log._LogAdapter(FakeLogger(), "testserver")
     self.assertEquals(a.getEffectiveLevel(), DEBUG)
Example #6
0
 def test_process(self):
     a = log._LogAdapter(None, "testserver")
     a.txn = "abc"
     self.assertEquals(a.process("test", {}), ("test", {"extra": {"txn": "abc", "server": "testserver"}}))
Example #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'}}))