diff --git a/nice.py b/nice.py index c5abdc5..0aa21dd 100644 --- a/nice.py +++ b/nice.py @@ -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"