From 43368e05f4041019a81f6e8f73c7b96b4d54556f Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Mon, 13 May 2024 15:13:25 +0200 Subject: [PATCH] refacto: use plugin title from metadata to name the logger --- qgis_resource_sharing/collection_manager.py | 3 ++- qgis_resource_sharing/gui/resource_sharing_dialog.py | 2 +- qgis_resource_sharing/network_manager.py | 3 ++- qgis_resource_sharing/repository_handler/base.py | 3 ++- .../repository_handler/filesystem_handler.py | 3 ++- .../repository_handler/remote_git_handler.py | 3 ++- .../repository_handler/remote_zip_handler.py | 3 ++- qgis_resource_sharing/repository_manager.py | 3 ++- qgis_resource_sharing/resource_handler/checklist_handler.py | 3 ++- qgis_resource_sharing/resource_handler/expression_handler.py | 3 ++- qgis_resource_sharing/resource_handler/model_handler.py | 3 ++- qgis_resource_sharing/resource_handler/processing_handler.py | 3 ++- qgis_resource_sharing/resource_handler/r_handler.py | 3 ++- qgis_resource_sharing/resource_handler/style_handler.py | 3 ++- qgis_resource_sharing/resource_handler/svg_handler.py | 3 ++- qgis_resource_sharing/resource_handler/symbol_handler.py | 3 ++- .../resource_handler/symbol_resolver_mixin.py | 3 ++- qgis_resource_sharing/symbol_xml_extractor.py | 4 +++- qgis_resource_sharing/utilities.py | 4 ++-- 19 files changed, 38 insertions(+), 20 deletions(-) diff --git a/qgis_resource_sharing/collection_manager.py b/qgis_resource_sharing/collection_manager.py index 38215274..6b1ab84f 100644 --- a/qgis_resource_sharing/collection_manager.py +++ b/qgis_resource_sharing/collection_manager.py @@ -6,6 +6,7 @@ from qgis.PyQt.QtCore import QObject, pyqtSignal from qgis_resource_sharing import config +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.config import ( COLLECTION_INSTALLED_STATUS, COLLECTION_NOT_INSTALLED_STATUS, @@ -19,7 +20,7 @@ resources_path, ) -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class CollectionInstaller(QObject): diff --git a/qgis_resource_sharing/gui/resource_sharing_dialog.py b/qgis_resource_sharing/gui/resource_sharing_dialog.py index cd52c710..031897ae 100644 --- a/qgis_resource_sharing/gui/resource_sharing_dialog.py +++ b/qgis_resource_sharing/gui/resource_sharing_dialog.py @@ -70,7 +70,7 @@ # -- GLOBALS FORM_CLASS, _ = uic.loadUiType(str(ui_path("resource_sharing_dialog_base.ui"))) -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) REPOSITORY_ITEM = 1000 COLLECTION_ITEM = 2000 diff --git a/qgis_resource_sharing/network_manager.py b/qgis_resource_sharing/network_manager.py index 3722939d..ef41fa63 100644 --- a/qgis_resource_sharing/network_manager.py +++ b/qgis_resource_sharing/network_manager.py @@ -4,9 +4,10 @@ from qgis.PyQt.QtCore import QCoreApplication, QUrl from qgis.PyQt.QtNetwork import QNetworkReply, QNetworkRequest +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.utilities import qgis_version -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class NetworkManager(object): diff --git a/qgis_resource_sharing/repository_handler/base.py b/qgis_resource_sharing/repository_handler/base.py index d139df02..437071a4 100644 --- a/qgis_resource_sharing/repository_handler/base.py +++ b/qgis_resource_sharing/repository_handler/base.py @@ -10,12 +10,13 @@ from qgis.core import Qgis from six import add_metaclass +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.config import COLLECTION_NOT_INSTALLED_STATUS from qgis_resource_sharing.exception import MetadataError from qgis_resource_sharing.network_manager import NetworkManager from qgis_resource_sharing.version_compare import isCompatible -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class RepositoryHandlerMeta(type): diff --git a/qgis_resource_sharing/repository_handler/filesystem_handler.py b/qgis_resource_sharing/repository_handler/filesystem_handler.py index a3a83022..13a9c9c8 100644 --- a/qgis_resource_sharing/repository_handler/filesystem_handler.py +++ b/qgis_resource_sharing/repository_handler/filesystem_handler.py @@ -4,10 +4,11 @@ from urllib.parse import urljoin from urllib.request import pathname2url +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.repository_handler.base import BaseRepositoryHandler from qgis_resource_sharing.utilities import local_collection_path -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class FileSystemHandler(BaseRepositoryHandler): diff --git a/qgis_resource_sharing/repository_handler/remote_git_handler.py b/qgis_resource_sharing/repository_handler/remote_git_handler.py index 0a6a17f1..74f6cf61 100644 --- a/qgis_resource_sharing/repository_handler/remote_git_handler.py +++ b/qgis_resource_sharing/repository_handler/remote_git_handler.py @@ -8,10 +8,11 @@ from giturlparse import parse, validate from qgis.core import QgsApplication +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.repository_handler.base import BaseRepositoryHandler from qgis_resource_sharing.utilities import local_collection_path -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class writeOut: diff --git a/qgis_resource_sharing/repository_handler/remote_zip_handler.py b/qgis_resource_sharing/repository_handler/remote_zip_handler.py index b2fc7e52..edad4567 100644 --- a/qgis_resource_sharing/repository_handler/remote_zip_handler.py +++ b/qgis_resource_sharing/repository_handler/remote_zip_handler.py @@ -4,11 +4,12 @@ from qgis.PyQt.QtCore import QTemporaryFile +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.network_manager import NetworkManager from qgis_resource_sharing.repository_handler.base import BaseRepositoryHandler from qgis_resource_sharing.utilities import local_collection_path -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class RemoteZipHandler(BaseRepositoryHandler): diff --git a/qgis_resource_sharing/repository_manager.py b/qgis_resource_sharing/repository_manager.py index 02eac4c4..af5e8afd 100644 --- a/qgis_resource_sharing/repository_manager.py +++ b/qgis_resource_sharing/repository_manager.py @@ -6,6 +6,7 @@ from qgis.PyQt.QtCore import QObject, QTemporaryFile from qgis_resource_sharing import config +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.collection_manager import CollectionManager from qgis_resource_sharing.config import COLLECTION_INSTALLED_STATUS from qgis_resource_sharing.exception import MetadataError @@ -17,7 +18,7 @@ repositories_cache_path, ) -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class RepositoryManager(QObject): diff --git a/qgis_resource_sharing/resource_handler/checklist_handler.py b/qgis_resource_sharing/resource_handler/checklist_handler.py index cea2bb79..5531db4e 100644 --- a/qgis_resource_sharing/resource_handler/checklist_handler.py +++ b/qgis_resource_sharing/resource_handler/checklist_handler.py @@ -4,11 +4,12 @@ from qgis.core import QgsApplication +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler CHECKLISTS_FOLDER = "checklists" CHECKLISTS = "checklists" # Resource Sharing collection subdirectory name -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class ChecklistHandler(BaseResourceHandler): diff --git a/qgis_resource_sharing/resource_handler/expression_handler.py b/qgis_resource_sharing/resource_handler/expression_handler.py index 983dd67e..c50147dc 100644 --- a/qgis_resource_sharing/resource_handler/expression_handler.py +++ b/qgis_resource_sharing/resource_handler/expression_handler.py @@ -4,13 +4,14 @@ from qgis.core import QgsSettings +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler from qgis_resource_sharing.utilities import user_expressions_group hasExprBuilder = False -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) EXPRESSIONS = "expressions" diff --git a/qgis_resource_sharing/resource_handler/model_handler.py b/qgis_resource_sharing/resource_handler/model_handler.py index d5c109ba..43f06e0e 100644 --- a/qgis_resource_sharing/resource_handler/model_handler.py +++ b/qgis_resource_sharing/resource_handler/model_handler.py @@ -5,11 +5,12 @@ from processing.tools.system import mkdir, userFolder from qgis.core import QgsApplication +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler MODELS_PROCESSING_FOLDER = "models" MODELS = "models" # Resource Sharing collection subdirectory name -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class ModelHandler(BaseResourceHandler): diff --git a/qgis_resource_sharing/resource_handler/processing_handler.py b/qgis_resource_sharing/resource_handler/processing_handler.py index 3451caa5..d929f1f0 100644 --- a/qgis_resource_sharing/resource_handler/processing_handler.py +++ b/qgis_resource_sharing/resource_handler/processing_handler.py @@ -5,9 +5,10 @@ from processing.script import ScriptUtils from qgis.core import QgsApplication +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) PROCESSING = "processing" diff --git a/qgis_resource_sharing/resource_handler/r_handler.py b/qgis_resource_sharing/resource_handler/r_handler.py index 62984d7b..9124dd2d 100644 --- a/qgis_resource_sharing/resource_handler/r_handler.py +++ b/qgis_resource_sharing/resource_handler/r_handler.py @@ -8,11 +8,12 @@ from processing.tools.system import mkdir, userFolder from qgis.core import QgsApplication +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler RSCRIPTS_PROCESSING_FOLDER = "rscripts" # Processing folder for R scripts RSCRIPTS_FOLDER = "rscripts" # Collection subfolder name -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class RScriptHandler(BaseResourceHandler): diff --git a/qgis_resource_sharing/resource_handler/style_handler.py b/qgis_resource_sharing/resource_handler/style_handler.py index 72a49e89..58428d8d 100644 --- a/qgis_resource_sharing/resource_handler/style_handler.py +++ b/qgis_resource_sharing/resource_handler/style_handler.py @@ -1,12 +1,13 @@ import logging from pathlib import Path +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler from qgis_resource_sharing.resource_handler.symbol_resolver_mixin import ( SymbolResolverMixin, ) -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) STYLE = "style" diff --git a/qgis_resource_sharing/resource_handler/svg_handler.py b/qgis_resource_sharing/resource_handler/svg_handler.py index 234ccd77..13fc8a7a 100644 --- a/qgis_resource_sharing/resource_handler/svg_handler.py +++ b/qgis_resource_sharing/resource_handler/svg_handler.py @@ -4,11 +4,12 @@ from qgis.core import Qgis, QgsSettings +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler from qgis_resource_sharing.utilities import local_collection_path SVG = "svg" -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class SVGResourceHandler(BaseResourceHandler): diff --git a/qgis_resource_sharing/resource_handler/symbol_handler.py b/qgis_resource_sharing/resource_handler/symbol_handler.py index 1f3cc558..022481de 100644 --- a/qgis_resource_sharing/resource_handler/symbol_handler.py +++ b/qgis_resource_sharing/resource_handler/symbol_handler.py @@ -3,6 +3,7 @@ from qgis.core import QgsStyle +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.resource_handler.base import BaseResourceHandler from qgis_resource_sharing.resource_handler.symbol_resolver_mixin import ( SymbolResolverMixin, @@ -10,7 +11,7 @@ from qgis_resource_sharing.symbol_xml_extractor import SymbolXMLExtractor from qgis_resource_sharing.utilities import qgis_version -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) SYMBOL = "symbol" diff --git a/qgis_resource_sharing/resource_handler/symbol_resolver_mixin.py b/qgis_resource_sharing/resource_handler/symbol_resolver_mixin.py index a274f648..9a948b5f 100644 --- a/qgis_resource_sharing/resource_handler/symbol_resolver_mixin.py +++ b/qgis_resource_sharing/resource_handler/symbol_resolver_mixin.py @@ -5,9 +5,10 @@ from qgis.core import QgsApplication from qgis.PyQt.QtCore import QFile, QFileInfo, QUrl +from qgis_resource_sharing.__about__ import __title__ from qgis_resource_sharing.utilities import path_leaf -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) class SymbolResolverMixin(object): diff --git a/qgis_resource_sharing/symbol_xml_extractor.py b/qgis_resource_sharing/symbol_xml_extractor.py index e19f328c..1514bf37 100644 --- a/qgis_resource_sharing/symbol_xml_extractor.py +++ b/qgis_resource_sharing/symbol_xml_extractor.py @@ -11,7 +11,9 @@ from qgis.PyQt.QtCore import QFile, QIODevice from qgis.PyQt.QtXml import QDomDocument -LOGGER = logging.getLogger("QGIS Resource Sharing") +from qgis_resource_sharing.__about__ import __title__ + +LOGGER = logging.getLogger(__title__) class SymbolXMLExtractor(object): diff --git a/qgis_resource_sharing/utilities.py b/qgis_resource_sharing/utilities.py index fa6c9545..3193a01a 100644 --- a/qgis_resource_sharing/utilities.py +++ b/qgis_resource_sharing/utilities.py @@ -8,9 +8,9 @@ from qgis.PyQt.QtCore import QDir from qgis_resource_sharing import config -from qgis_resource_sharing.__about__ import DIR_PLUGIN_ROOT +from qgis_resource_sharing.__about__ import DIR_PLUGIN_ROOT, __title__ -LOGGER = logging.getLogger("QGIS Resource Sharing") +LOGGER = logging.getLogger(__title__) SUPPORTED_RESOURCES_MAP = { "svg": "SVG",