1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-02-21 22:06:57 +00:00

Add date-based log rotation. Partially fixes last part of #121. (#248)

This commit is contained in:
Manuel Riel 2019-04-19 13:23:02 +08:00 committed by GitHub
parent 4f799ed63f
commit b470d84c50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@
import os
import logging
from logging.handlers import TimedRotatingFileHandler
from .config import LOG_DIR
logger = logging.getLogger()
@ -23,7 +24,10 @@ def init_logger(foreground=False):
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# create handlers
fh = logging.FileHandler(os.path.join(LOG_DIR, 'vorta.log'))
fh = TimedRotatingFileHandler(os.path.join(LOG_DIR, 'vorta.log'),
when='d',
interval=1,
backupCount=5)
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
logger.addHandler(fh)