From 22d8f29771cb51f1641e0b6e972df3aff5fb2eed Mon Sep 17 00:00:00 2001 From: Zalk0 <88582103+zalk0@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:03:25 +0100 Subject: [PATCH] fix: site access is debug level now --- chouette/bot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/chouette/bot.py b/chouette/bot.py index fd182e8..495ff5f 100644 --- a/chouette/bot.py +++ b/chouette/bot.py @@ -130,9 +130,17 @@ async def start_server(self) -> None: """Démarre un serveur HTTP pour vérifier si le bot est en ligne.""" # Set a logger for the webserver web_logger = logging.getLogger("web") - # Don't want to spam logs with site access - if self.log_level >= logging.INFO: - logging.getLogger("aiohttp.access").setLevel(logging.ERROR) + + # Switch site access log to DEBUG level + def access_filter(record: logging.LogRecord) -> bool: + if record.levelno == logging.INFO: + if self.log_level >= logging.INFO: + return False + record.levelno = logging.DEBUG + record.levelname = "DEBUG" + return True + + logging.getLogger("aiohttp.access").addFilter(access_filter) # Set some basic headers for security headers = {