def ping(self): payload = {"start_time": "%s" % self._start_time, "client": self._client.id, "questions": self._client.num_questions } payload['bots'] = self._client.get_question_counts() payload['logging'] = YLogger.snapshot().to_json() return payload
def test_ylogger_warning(self): client_context = ClientContext(TestClient(), "testid") YLogger.reset_snapshot() YLogger.warning(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual( str(snapshot), "Critical(0) Fatal(0) Error(0) Exception(0) Warning(1) Info(0), Debug(0)" )
def test_ylogger(self): client_context = ClientContext(TestClient(), "testid") snapshot = YLoggerSnapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(0) Fatal(0) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.reset_snapshot() YLogger.critical(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(0) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.fatal(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.error(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.exception(client_context, "Test Message", Exception("Test error")) snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(0) Info(0), Debug(0)") YLogger.warning(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(0), Debug(0)") YLogger.info(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(1), Debug(0)") YLogger.debug(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEqual(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(1), Debug(1)")
def test_ylogger(self): client_context = ClientContext(TestClient(), "testid") snapshot = YLoggerSnapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(0) Fatal(0) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.reset_snapshot() YLogger.critical(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(0) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.fatal(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(0) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.error(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(0) Warning(0) Info(0), Debug(0)") YLogger.exception(client_context, "Test Message", Exception("Test error")) snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(0) Info(0), Debug(0)") YLogger.warning(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(0), Debug(0)") YLogger.info(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(1), Debug(0)") YLogger.debug(client_context, "Test Message") snapshot = YLogger.snapshot() self.assertIsNotNone(snapshot) self.assertEquals(str(snapshot), "Critical(1) Fatal(1) Error(1) Exception(1) Warning(1) Info(1), Debug(1)")