Skip to content

Commit d669502

Browse files
committed
Fix: Include system info after log rollover
1 parent e9c0a1b commit d669502

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

BabbleApp/logger.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def log_system_info(logger):
3838
except Exception as e:
3939
logger.error(f"Failed to log system information: {e}")
4040

41+
class _RotatingFileHandler(RotatingFileHandler):
42+
def doRollover(self):
43+
super().doRollover()
44+
# Include system info after rollover
45+
log_system_info(logging.getLogger("debug_logger"))
4146

4247
def setup_logging():
4348
# Log to program directory
@@ -49,7 +54,7 @@ def setup_logging():
4954
logger = logging.getLogger("debug_logger")
5055
logger.setLevel(logging.DEBUG)
5156

52-
file_handler = RotatingFileHandler(log_file, mode='w', maxBytes=2000000, backupCount=1, encoding='utf-8')
57+
file_handler = _RotatingFileHandler(log_file, mode='w', maxBytes=2000000, backupCount=1, encoding='utf-8')
5358
file_handler.setLevel(logging.DEBUG)
5459
formatter = logging.Formatter('%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
5560
file_handler.setFormatter(formatter)

0 commit comments

Comments
 (0)