From ca14e931f8d3b7533053bbc9a3a9592ef095d6d9 Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Sat, 20 Jun 2026 17:04:24 +0800 Subject: [PATCH] =?UTF-8?q?QGIS=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/paths.py | 20 +++++++++++--------- app/script/run_qgis.bat | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/config/paths.py b/app/config/paths.py index 65410a8..b8868ff 100644 --- a/app/config/paths.py +++ b/app/config/paths.py @@ -19,13 +19,15 @@ DBN_CONFIG_DIR = CONFIG_DIR / "dbn" def get_logger(name: str = "algorithm"): """ - 获取日志记录器的便捷函数 - - Args: - name: 日志名称 - - Returns: - logging.Logger 实例 + 获取日志记录器。主进程用 loguru,QGIS 子进程回退到标准 logging。 """ - from app.utils.logger import get_logger as _get_logger - return _get_logger(name, str(LOG_DIR)) + try: + from app.utils.logger import get_logger as _get_logger + return _get_logger(name, str(LOG_DIR)) + except ImportError: + import logging + logging.basicConfig( + level=logging.INFO, + format="%(asctime)s [%(threadName)s] %(levelname)-5s %(name)s - %(message)s", + ) + return logging.getLogger(name) diff --git a/app/script/run_qgis.bat b/app/script/run_qgis.bat index d2303d5..c5e37d7 100644 --- a/app/script/run_qgis.bat +++ b/app/script/run_qgis.bat @@ -30,6 +30,8 @@ set "GDAL_FILENAME_IS_UTF8=YES" set "VSI_CACHE=TRUE" set "VSI_CACHE_SIZE=1000000" set "PATH=%QGIS_APP%\bin;%QGIS_ROOT%\apps\Qt5\bin;%QGIS_ROOT%\apps\gdal\lib;%PATH%" +REM 强制使用 QGIS 自带的 PROJ,避免 PostgreSQL/PostGIS 的旧 proj.db 干扰 +if exist "%QGIS_ROOT%\share\proj" set "PROJ_DATA=%QGIS_ROOT%\share\proj" REM --- 启动 --- "%PY%\python3.exe" %*