[MetaSearch] Allow the user to enable or disable the logging of the debug messages (#60049)

* [metasearch] Add setting to enable/disable debug logging

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andrea Giudiceandrea 2025-01-06 00:41:24 +01:00 committed by GitHub
parent 6f4df5d107
commit b3a7f06465
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 1 deletions

View File

@ -119,6 +119,9 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
self.disable_ssl_verification = self.settings.value(
"/MetaSearch/disableSSL", False, bool
)
self.log_debugging_messages = self.settings.value(
"/MetaSearch/logDebugging", False, bool
)
# Services tab
self.cmbConnectionsServices.activated.connect(self.save_connection)
@ -181,6 +184,10 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
self.settings.setValue("/MetaSearch/disableSSL", bool(state))
self.disable_ssl_verification = bool(state)
def _on_debugging_state_change(state):
self.settings.setValue("/MetaSearch/logDebugging", bool(state))
self.log_debugging_messages = bool(state)
self.tabWidget.setCurrentIndex(0)
self.populate_connection_list()
self.btnRawAPIResponse.setEnabled(False)
@ -192,6 +199,8 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
self.spnTimeout.valueChanged.connect(_on_timeout_change)
self.disableSSLVerification.setChecked(self.disable_ssl_verification)
self.disableSSLVerification.stateChanged.connect(_on_ssl_state_change)
self.logDebuggingMessages.setChecked(self.log_debugging_messages)
self.logDebuggingMessages.stateChanged.connect(_on_debugging_state_change)
key = "/MetaSearch/%s" % self.cmbConnectionsSearch.currentText()
self.catalog_url = self.settings.value("%s/url" % key)

View File

@ -558,6 +558,36 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Debugging</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Log debugging messages</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="logDebuggingMessages">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -174,4 +174,6 @@ def clean_ows_url(url):
def log_message(message, level=Qgis.MessageLevel.Info):
"""helper function to emit logging messages"""
LOGGER.logMessage(message, "MetaSearch", level)
logging = QgsSettings().value("/MetaSearch/logDebugging", False, bool)
if logging:
LOGGER.logMessage(message, "MetaSearch", level)