def test_log(self): Utils.prepare_test(connect_logger=True) Logger.log(Logger.DEBUG, "FOO_CAT", "Log message") Logger.c.execute("SELECT * FROM logs WHERE category = 'FOO_CAT'") row = Logger.c.fetchone() self.assertEqual("FOO_CAT", row[1]) self.assertEqual(Logger.DEBUG, int(row[2])) self.assertEqual("Log message", row[3])
def append_log(self, append_log_secret: str, level: str, category: str, message: str): """ POST /admin/append_log """ if append_log_secret != Config.append_log_secret: self.raise_exc(Forbidden, "FORBIDDEN", "Invalid append log secret") if level not in Logger.HUMAN_MESSAGES: self.raise_exc(BadRequest, "INVALID_PARAMETER", "The level provided is invalid") level = Logger.HUMAN_MESSAGES.index(level) Logger.log(level, category, message)