Patch for removing common error with logging

pull/1/head
hikariatama 2022-05-12 12:19:34 +00:00
parent e713035099
commit 9664d0e4f7
1 changed files with 3 additions and 7 deletions

View File

@ -91,17 +91,16 @@ class TelegramLogsHandler(logging.Handler):
self.tg_buff = ""
if len(self._queue) > 5:
file = io.BytesIO("".join(self._queue).encode("utf-8"))
file.name = "hikka-logs.txt"
file.seek(0)
for mod in self._mods.values():
file = io.BytesIO("".join(self._queue).encode("utf-8"))
file.name = "hikka-logs.txt"
file.seek(0)
await mod.inline.bot.send_document(
mod._logchat,
file,
parse_mode="HTML",
caption="<b>🧳 Journals are too big to send as separate messages</b>",
)
file.seek(0)
self._queue = []
return
@ -144,9 +143,6 @@ class TelegramLogsHandler(logging.Handler):
except TypeError:
self.tg_buff += f"[{record.levelname}] {record.name}: {record.msg}\n"
if exc:
asyncio.ensure_future(self.emit_to_tg())
if len(self.buffer) + len(self.handledbuffer) >= self.capacity:
if self.handledbuffer:
del self.handledbuffer[0]