From 0ab7c11cb8e71ff28d3626114b24592eec49ebf5 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 5 Aug 2018 20:44:35 +0100 Subject: [PATCH] use TimeRotatingFileHandler in logging.py --- modules/logging.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/logging.py b/modules/logging.py index 4876741b..46f8bb29 100644 --- a/modules/logging.py +++ b/modules/logging.py @@ -1,4 +1,4 @@ -import logging, sys, time +import logging, logging.handlers, sys, time class BitBotFormatter(logging.Formatter): def formatTime(self, record, datefmt=None): @@ -27,7 +27,8 @@ class Module(object): stdout_handler.setFormatter(formatter) self.logger.addHandler(stdout_handler) - file_handler = logging.FileHandler('bot.log') + file_handler = logging.handlers.TimedRotatingFileHandler( + "bot.log", when="midnight", backupCount=5) file_handler.setLevel(logging.DEBUG) file_handler.setFormatter(formatter) self.logger.addHandler(file_handler)