From 738337b67304709b188e2c01e37afa412bf05567 Mon Sep 17 00:00:00 2001 From: dan63047 Date: Mon, 8 Jun 2020 21:52:51 +0300 Subject: [PATCH] !debug log fix --- dan63047bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dan63047bot.py b/dan63047bot.py index a0dc215..175f2da 100644 --- a/dan63047bot.py +++ b/dan63047bot.py @@ -17,9 +17,11 @@ from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType root_logger = logging.getLogger() root_logger.setLevel(logging.INFO) try: - handler = logging.FileHandler(f'logs/bot_log{str(datetime.datetime.now())}.log', 'w', 'utf-8') + log_path = f'logs/bot_log{str(datetime.datetime.now())}.log' + handler = logging.FileHandler(log_path, 'w', 'utf-8') except: - handler = logging.FileHandler('bot.log', 'w', 'utf-8') + log_path = 'bot.log' + handler = logging.FileHandler(log_path, 'w', 'utf-8') handler.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s')) root_logger.addHandler(handler) @@ -449,7 +451,7 @@ class VkBot: def debug(self, arg=None): if arg == "log": if self._OWNER: - with open("bot.log", 'r') as f: + with open(log_path, 'r') as f: log = list(deque(f, 10)) text_log = "
Последние 10 строк из лога:
" for i in range(len(log)):