mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-10-16 15:06:04 +08:00
Telegram long-polling floods the log in two ways: 1. python-telegram-bot performs getUpdates through httpx, which logs every request at INFO level. httpx/httpcore were missing from LogManager._NOISY_LOGGER_LEVELS, so those per-request lines (one every ~10s) leaked through. 2. _on_polling_error logged a full traceback for every polling error, including non-network errors such as Conflict (two bot instances polling the same token). Log a concise one-line message for non-network errors and keep the traceback only for NetworkError, which still needs it for recovery.
This commit is contained in:
@@ -203,6 +203,8 @@ class LogManager:
|
||||
"asyncio": logging.WARNING,
|
||||
"tzlocal": logging.WARNING,
|
||||
"apscheduler": logging.WARNING,
|
||||
"httpx": logging.WARNING,
|
||||
"httpcore": logging.WARNING,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -290,12 +290,19 @@ class TelegramPlatformAdapter(Platform):
|
||||
await asyncio.sleep(self._polling_restart_delay)
|
||||
|
||||
def _on_polling_error(self, error: Exception) -> None:
|
||||
# Non-network errors (e.g. Conflict when two bot instances poll the
|
||||
# same token) have a clear cause; log a concise message instead of a
|
||||
# full traceback to avoid filling the log.
|
||||
if not isinstance(error, NetworkError):
|
||||
logger.error(
|
||||
f"Telegram polling request failed: {type(error).__name__}: {error!s}"
|
||||
)
|
||||
return
|
||||
|
||||
logger.error(
|
||||
f"Telegram polling request failed: {type(error).__name__}: {error!s}",
|
||||
exc_info=error,
|
||||
)
|
||||
if not isinstance(error, NetworkError):
|
||||
return
|
||||
|
||||
if self._loop is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user