def test_exception_is_none_with_stderror(self):
        client = TestClient()
        client_context = ClientContext(client, "testid")
        logging.getLogger().setLevel(level=logging.DEBUG)
        YLogger.set_stderr("True")

        YLogger.exception(client_context, "Exception Log", None)
    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 #3
0
    def __init__(self, id, argument_parser=None):
        RestBotClient.__init__(self, id, argument_parser)
        self.initialise()

        bot_name = "defaultbot"
        try:
            bot = self._bot_factory.select_bot()
            brain = bot._brain_factory.select_brain()
            bot_name = brain.configuration.bot_name

            YLogger.set_prefix(bot_name)
        except Exception:
            pass

        self._server_mode = True  # if Not Server-Mode then change to comment line.
        YLogger.set_stdout(self.arguments.args.stdoutlog)
        YLogger.set_stderr(self.arguments.args.stderrlog)
        YLogger.set_traceback(False)
    def test_set_stderror_json(self):
        client = TestClient()
        client_context = ClientContext(client, "testid")

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

        tmp_str = 'test'
        tmp_val = 99
        YLogger.debug(client_context, '{"key_a":"%s", "key_b": "%d"}', tmp_str, tmp_val)

        YLogger.debug(client_context, '{"key_a":"%s", "key_b": "%d"}')

        json_data1 = '{"key_a":"%s", "key_b": "%d"}' % (tmp_str, tmp_val)
        YLogger.debug(client_context, 'json_data : "%s"', json_data1)

        json_data2 = '{"key_a":"%s", "key_b": "%d"}'
        YLogger.debug(client_context, 'json_data : "%s"', json_data2)