Change file handler to rotate logs

This commit is contained in:
Tim Van Baak 2020-12-30 13:06:12 -08:00
parent 193b445bd5
commit ec2382e1bd
1 changed files with 5 additions and 1 deletions

View File

@ -135,7 +135,11 @@ def add_logging_handler(verbose, log_filename):
logging.INFO
)
handler = (
logging.FileHandler(log_filename, encoding='utf8')
logging.handlers.RotatingFileHandler(
log_filename,
encoding='utf8',
maxBytes=2**22, # 4 MB per log file
backupCount=4) # 16 MB total
if log_filename else
logging.StreamHandler()
)