refactor logging setup: improve log file path handling for development and frozen application
This commit is contained in:
@@ -71,7 +71,20 @@ DELETE_FILES_ON_UPLOAD = True
|
||||
DEBUG = False
|
||||
|
||||
logging.getLogger('niceGUI').setLevel(logging.INFO)
|
||||
logger.add("uploader.log", rotation="10 MB")
|
||||
|
||||
# Choose a log file path that works both during development and when the
|
||||
# application is frozen into a single executable (PyInstaller --onefile).
|
||||
try:
|
||||
if getattr(sys, "frozen", False):
|
||||
# When frozen, place logs next to the executable
|
||||
base_path = Path(sys.executable).resolve().parent
|
||||
else:
|
||||
base_path = Path(__file__).resolve().parent
|
||||
except Exception:
|
||||
base_path = Path.cwd()
|
||||
|
||||
log_path = base_path / "uploader.log"
|
||||
logger.add(str(log_path), rotation="10 MB")
|
||||
|
||||
if DEBUG:
|
||||
BASE_SITE_URL = "http://localhost:8000"
|
||||
|
||||
Reference in New Issue
Block a user