We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c66d5c4 commit 55866d0Copy full SHA for 55866d0
1 file changed
prime_backup/utils/log_utils.py
@@ -1,5 +1,6 @@
1
import contextlib
2
import logging
3
+from logging.handlers import RotatingFileHandler
4
from pathlib import Path
5
from typing import Generator
6
@@ -15,7 +16,12 @@ def __init__(self, name: str):
15
16
super().__init__(f'{constants.PLUGIN_ID}-{name}', get_log_level())
17
self.log_file = self.__get_log_file_path(f'{name}.log')
18
self.log_file.parent.mkdir(parents=True, exist_ok=True)
- handler = logging.FileHandler(self.log_file, encoding='utf8')
19
+ handler = RotatingFileHandler(
20
+ self.log_file,
21
+ maxBytes=10 * 1024 * 1024,
22
+ backupCount=1,
23
+ encoding='utf8'
24
+ )
25
handler.setFormatter(LOG_FORMATTER)
26
self.addHandler(handler)
27
0 commit comments