Make debug log configurable

This commit is contained in:
Anton Thomasson 2022-01-19 20:03:19 +01:00
parent 40e7f32846
commit 390e5dd16d
11 changed files with 86 additions and 1 deletions

View file

@ -152,5 +152,12 @@ ApplicationWindow
defaultValue: SeaPrintSettings.ignoreSslErrorsDefault
}
ConfigurationValue
{
id: debugLogSetting
key: SeaPrintSettings.debugLogPath
defaultValue: SeaPrintSettings.debugLogDefault
}
}

View file

@ -53,6 +53,15 @@ Page {
}
}
TextSwitch {
text: qsTr("Enable debug log")
description: qsTr("Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.")
checked: debugLogSetting.value
onCheckedChanged: {
debugLogSetting.value = checked
}
}
}
}
}

View file

@ -27,6 +27,9 @@ int main(int argc, char *argv[])
qRegisterMetaType<CURLcode>();
qRegisterMetaType<Bytestream>();
// Turn on/off logging according to setting
QLoggingCategory::defaultCategory()->setEnabled(QtMsgType::QtDebugMsg, Settings::instance()->debugLog());
QGuiApplication* app = SailfishApp::application(argc, argv);
app->setOrganizationName(QStringLiteral("net.attah"));

View file

@ -2,7 +2,8 @@
#include <QMutex>
Settings::Settings() : _ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this)
Settings::Settings() : _ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this),
_debugLogSetting("/apps/harbour-seaprint/settings/debug-log", this)
{
}
@ -37,3 +38,13 @@ QString Settings::ignoreSslErrorsPath()
{
return _ignoreSslErrorsSetting.key();
}
bool Settings::debugLog()
{
return _debugLogSetting.value(_debugLogDefault).toBool();
}
QString Settings::debugLogPath()
{
return _debugLogSetting.key();
}

View file

@ -10,11 +10,14 @@ public:
Q_PROPERTY(QString ignoreSslErrorsPath READ ignoreSslErrorsPath CONSTANT)
Q_PROPERTY(bool ignoreSslErrorsDefault MEMBER _ignoreSslErrorsDefault CONSTANT)
Q_PROPERTY(QString debugLogPath READ debugLogPath CONSTANT)
Q_PROPERTY(bool debugLogDefault MEMBER _debugLogDefault CONSTANT)
public:
static Settings* instance();
bool ignoreSslErrors();
bool debugLog();
private:
Settings();
@ -25,10 +28,14 @@ private:
static Settings* m_Instance;
MGConfItem _ignoreSslErrorsSetting;
MGConfItem _debugLogSetting;
QString ignoreSslErrorsPath();
QString debugLogPath();
bool _ignoreSslErrorsDefault = true;
bool _debugLogDefault = false;
};
#endif // SETTINGS_H

View file

@ -569,6 +569,14 @@ auf diesem Drucker</translation>
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation>Um mit selbstsignierten Zertifikaten von Druckern und CUPS-Instanzen arbeiten zu können, müssen SSL-Fehler ignoriert werden.</translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>

View file

@ -568,6 +568,14 @@
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation>Para funcionar con certificados autofirmados de impresoras e instancias de CUPS, se deben ignorar los errores de SSL.</translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>

View file

@ -569,6 +569,14 @@ sur cette imprimante</translation>
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation>Afin de fonctionner avec des certificats autosignés des imprimantes et des instances CUPS, les erreurs SSL doivent être ignorées.</translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>

View file

@ -568,6 +568,14 @@
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation>Om te kunnen werken met zelfondertekende certificaten van printers en CUPS-instanties, moeten SSL-fouten worden genegeerd.</translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>

View file

@ -568,6 +568,14 @@
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>

View file

@ -568,6 +568,14 @@
<source>In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable debug log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupplyItem</name>