def test_check_log_not_output(self):
        logging.getLogger().setLevel(level=logging.NOTSET)
        YLogger.set_default_level()

        YLogger.critical(None, "Critical Log")
        YLogger.fatal(None, "Fatal Log")
        YLogger.error(None, "Error Log")
        YLogger.exception(None, "Exception Log", Exception("test"))
        YLogger.warning(None, "Warning Log")
        YLogger.info(None, "Info Log")
        YLogger.debug(None, "Debug Log")
Exemple #2
0
    def test_ylogger_fatal(self):
        client_context = ClientContext(TestClient(), "testid")
        YLogger.reset_snapshot()

        YLogger.fatal(client_context, "Test Message")
        snapshot = YLogger.snapshot()
        self.assertIsNotNone(snapshot)
        self.assertEqual(
            str(snapshot),
            "Critical(0) Fatal(1) Error(0) Exception(0) Warning(0) Info(0), Debug(0)"
        )
    def test_set_stderror(self):
        client = TestClient()
        client_context = ClientContext(client, "testid")

        logging.getLogger().setLevel(level=logging.DEBUG)
        YLogger.set_stderr("True")

        YLogger.critical(client_context, "Critical Log")
        YLogger.fatal(client_context, "Fatal Log")
        YLogger.error(client_context, "Error Log")
        YLogger.exception(client_context, "Exception Log", Exception("test"))
        YLogger.warning(client_context, "Warning Log")
        YLogger.info(client_context, "Info Log")
        YLogger.debug(client_context, "Debug Log")
Exemple #4
0
    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)")