From 1332d8aaf4843e22c0633b8e231c04a7ef64d22e Mon Sep 17 00:00:00 2001 From: dan63047 Date: Wed, 10 Jun 2020 20:42:30 +0300 Subject: [PATCH] new log format --- dan63047bot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dan63047bot.py b/dan63047bot.py index 4e036ce..94ede6b 100644 --- a/dan63047bot.py +++ b/dan63047bot.py @@ -22,17 +22,19 @@ try: except: log_path = 'bot.log' handler = logging.FileHandler(log_path, 'w', 'utf-8') -handler.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s')) +handler.setFormatter(logging.Formatter('%(message)s')) root_logger.addHandler(handler) def log(warning, text): if warning: - logging.warning(text) + msg = "[" + str(datetime.datetime.now()) + "] [WARNING] " + text + logging.warning(msg) + print(msg) debug_array['logger_warnings'] += 1 - print("[" + str(datetime.datetime.now()) + "] [WARNING] " + text) else: - logging.info(text) - print("[" + str(datetime.datetime.now()) + "] " + text) + msg = "[" + str(datetime.datetime.now()) + "] " + text + logging.info(msg) + print(msg) log(False, "Script started")