fix to log file growing
This commit is contained in:
1 parent
2e9820336d
commit
8270d7b7a8
2 files changed
+26
-9
No files matched your search
@@ -14,6 +14,7 @@ import sys
|
|||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import logging.handlers
|
||||||
import warnings
|
import warnings
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
@@ -310,21 +311,37 @@ script_dir = os.path.dirname(os.path.abspath(__file__))
|
|||||||
os.chdir(script_dir)
|
os.chdir(script_dir)
|
||||||
|
|
||||||
|
|
||||||
# Configure logging to file with timestamps and realtime flush
|
|
||||||
|
# Configure logging with rotation to prevent indefinite growth
|
||||||
if PLATFORM_NAME == 'darwin':
|
if PLATFORM_NAME == 'darwin':
|
||||||
log_path = os.path.abspath(os.path.join(os.path.dirname(sys.executable), "../../../fnirs_analysis.log"))
|
log_path = os.path.abspath(os.path.join(os.path.dirname(sys.executable), "../../../fnirs_analysis.log"))
|
||||||
else:
|
else:
|
||||||
log_path = os.path.join(get_app_dir(), "fnirs_analysis.log")
|
log_path = os.path.join(get_app_dir(), "fnirs_analysis.log")
|
||||||
|
|
||||||
logging.basicConfig(
|
# Create logger
|
||||||
filename=log_path,
|
logger = logging.getLogger()
|
||||||
level=logging.INFO,
|
logger.setLevel(logging.INFO)
|
||||||
format='%(asctime)s - %(processName)s - %(levelname)s - %(message)s',
|
|
||||||
datefmt='%Y-%m-%d %H:%M:%S',
|
# Clear any existing handlers
|
||||||
filemode='a'
|
logger.handlers.clear()
|
||||||
|
|
||||||
|
# Create rotating file handler (max 10MB per file, keep 5 backups = ~50MB max total)
|
||||||
|
rotating_handler = logging.handlers.RotatingFileHandler(
|
||||||
|
log_path,
|
||||||
|
maxBytes=10*1024*1024, # 10 MB
|
||||||
|
backupCount=5, # Keep 5 backup files
|
||||||
|
encoding='utf-8'
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
# Set formatter
|
||||||
|
formatter = logging.Formatter(
|
||||||
|
'%(asctime)s - %(processName)s - %(levelname)s - %(message)s',
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
)
|
||||||
|
rotating_handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
# Add handler to logger
|
||||||
|
logger.addHandler(rotating_handler)
|
||||||
|
|
||||||
|
|
||||||
def set_config_me(config: dict[str, Any]) -> None:
|
def set_config_me(config: dict[str, Any]) -> None:
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
winreg = None
|
winreg = None
|
||||||
|
|
||||||
CURRENT_VERSION = "1.8.1"
|
CURRENT_VERSION = "1.8.2"
|
||||||
APP_NAME = "flares"
|
APP_NAME = "flares"
|
||||||
APP_NAME_EXPANDED = "fNIRS Lightweight Analysis, Research, & Evaluation Suite"
|
APP_NAME_EXPANDED = "fNIRS Lightweight Analysis, Research, & Evaluation Suite"
|
||||||
API_URL = f"https://git.research.dezeeuw.ca/api/v1/repos/tyler/{APP_NAME}/releases"
|
API_URL = f"https://git.research.dezeeuw.ca/api/v1/repos/tyler/{APP_NAME}/releases"
|
||||||
|
|||||||
Reference in new issue
Block a user