Files
dotfiles/pkgs/piano-led-visualizer/fix-log-dir.patch

25 lines
766 B
Diff

diff --git a/lib/log_setup.py b/lib/log_setup.py
index 34f9156..e164d14 100644
--- a/lib/log_setup.py
+++ b/lib/log_setup.py
@@ -1,6 +1,7 @@
import logging
from logging.handlers import RotatingFileHandler
import sys
+import os
# Create a custom logger
logger = logging.getLogger("my_app")
@@ -10,7 +11,10 @@ logger.setLevel(logging.DEBUG)
# Create handlers
console_handler = logging.StreamHandler()
-file_handler = RotatingFileHandler('/home/Piano-LED-Visualizer/visualizer.log', maxBytes=500000, backupCount=10)
+
+log_path = os.path.expanduser('~/Piano-LED-Visualizer/visualizer.log')
+os.makedirs(os.path.dirname(log_path), exist_ok=True)
+file_handler = RotatingFileHandler(log_path, maxBytes=500000, backupCount=10)
# Set the level for handlers