feat: add new setting Log::GuiDebug to control when the Gui shows debug messages no longer controled by an ENV var
This commit is contained in:
parent
67ceedcad0
commit
aba38b949f
11 changed files with 113 additions and 113 deletions
|
|
@ -802,24 +802,3 @@ section: links
|
||||||
down = larry
|
down = larry
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example `.env` file
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
#
|
|
||||||
# App
|
|
||||||
#
|
|
||||||
|
|
||||||
# Shows the test menu in the GUI (on by default in debug mode)
|
|
||||||
# DESKFLOW_TEST_MENU=true
|
|
||||||
|
|
||||||
# Version checker URL to use (useful for testing)
|
|
||||||
# DESKFLOW_VERSION_URL="https://api.deskflow.org/version?fake=1.100.0"
|
|
||||||
|
|
||||||
# Enable debug logging in the GUI (on by default in debug mode)
|
|
||||||
# DESKFLOW_GUI_DEBUG=true
|
|
||||||
|
|
||||||
# Enable verbose logging in the GUI (always off by default)
|
|
||||||
# DESKFLOW_GUI_VERBOSE=true
|
|
||||||
```
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,6 @@ int main(int argc, char *argv[])
|
||||||
qInfo("%s v%s", kAppName, kDisplayVersion);
|
qInfo("%s v%s", kAppName, kDisplayVersion);
|
||||||
|
|
||||||
dotenv();
|
dotenv();
|
||||||
Logger::instance()->loadEnvVars();
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public:
|
||||||
inline static const auto File = QStringLiteral("log/file");
|
inline static const auto File = QStringLiteral("log/file");
|
||||||
inline static const auto Level = QStringLiteral("log/level");
|
inline static const auto Level = QStringLiteral("log/level");
|
||||||
inline static const auto ToFile = QStringLiteral("log/toFile");
|
inline static const auto ToFile = QStringLiteral("log/toFile");
|
||||||
|
inline static const auto GuiDebug = QStringLiteral("log/guiDebug");
|
||||||
};
|
};
|
||||||
struct Security
|
struct Security
|
||||||
{
|
{
|
||||||
|
|
@ -185,6 +186,7 @@ private:
|
||||||
, Settings::Log::File
|
, Settings::Log::File
|
||||||
, Settings::Log::Level
|
, Settings::Log::Level
|
||||||
, Settings::Log::ToFile
|
, Settings::Log::ToFile
|
||||||
|
, Settings::Log::GuiDebug
|
||||||
, Settings::Gui::Autohide
|
, Settings::Gui::Autohide
|
||||||
, Settings::Gui::AutoUpdateCheck
|
, Settings::Gui::AutoUpdateCheck
|
||||||
, Settings::Gui::CloseReminder
|
, Settings::Gui::CloseReminder
|
||||||
|
|
@ -209,6 +211,7 @@ private:
|
||||||
, Settings::Server::ExternalConfig
|
, Settings::Server::ExternalConfig
|
||||||
, Settings::Client::InvertScrollDirection
|
, Settings::Client::InvertScrollDirection
|
||||||
, Settings::Log::ToFile
|
, Settings::Log::ToFile
|
||||||
|
, Settings::Log::GuiDebug
|
||||||
};
|
};
|
||||||
|
|
||||||
// When checking the default values this list contains the ones that default to true.
|
// When checking the default values this list contains the ones that default to true.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "common/Settings.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
@ -49,14 +50,8 @@ QString printLine(FILE *out, const QString &type, const QString &message, const
|
||||||
return logLine;
|
return logLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::loadEnvVars()
|
|
||||||
{
|
|
||||||
m_debug = QVariant(qEnvironmentVariable("DESKFLOW_GUI_DEBUG")).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const QString &message)
|
void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const QString &message)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto mutatedType = type;
|
auto mutatedType = type;
|
||||||
if (kForceDebugMessages.contains(message)) {
|
if (kForceDebugMessages.contains(message)) {
|
||||||
mutatedType = QtDebugMsg;
|
mutatedType = QtDebugMsg;
|
||||||
|
|
@ -66,10 +61,9 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
|
||||||
auto out = stdout;
|
auto out = stdout;
|
||||||
switch (mutatedType) {
|
switch (mutatedType) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
typeString = "DEBUG";
|
if (!Settings::value(Settings::Log::GuiDebug).toBool())
|
||||||
if (!m_debug) {
|
|
||||||
return;
|
return;
|
||||||
}
|
typeString = "DEBUG";
|
||||||
break;
|
break;
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
typeString = "INFO";
|
typeString = "INFO";
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,10 @@ public:
|
||||||
return &m;
|
return &m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadEnvVars();
|
|
||||||
void handleMessage(const QtMsgType type, const QString &fileLine, const QString &message);
|
void handleMessage(const QtMsgType type, const QString &fileLine, const QString &message);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void newLine(const QString &line);
|
void newLine(const QString &line);
|
||||||
|
|
||||||
private:
|
|
||||||
#ifdef NDEBUG
|
|
||||||
bool m_debug = false;
|
|
||||||
#else
|
|
||||||
bool m_debug = true;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deskflow::gui
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ void SettingsDialog::accept()
|
||||||
Settings::setValue(Settings::Security::CheckPeers, ui->cbRequireClientCert->isChecked());
|
Settings::setValue(Settings::Security::CheckPeers, ui->cbRequireClientCert->isChecked());
|
||||||
Settings::setValue(Settings::Client::ScrollSpeed, ui->sbScrollSpeed->value());
|
Settings::setValue(Settings::Client::ScrollSpeed, ui->sbScrollSpeed->value());
|
||||||
Settings::setValue(Settings::Core::Language, ui->comboLanguage->currentText());
|
Settings::setValue(Settings::Core::Language, ui->comboLanguage->currentText());
|
||||||
|
Settings::setValue(Settings::Log::GuiDebug, ui->cbGuiDebug->isChecked());
|
||||||
|
|
||||||
Settings::ProcessMode mode;
|
Settings::ProcessMode mode;
|
||||||
if (ui->groupService->isChecked())
|
if (ui->groupService->isChecked())
|
||||||
|
|
@ -203,6 +204,7 @@ void SettingsDialog::loadFromConfig()
|
||||||
ui->cbElevateDaemon->setChecked(Settings::value(Settings::Daemon::Elevate).toBool());
|
ui->cbElevateDaemon->setChecked(Settings::value(Settings::Daemon::Elevate).toBool());
|
||||||
ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool());
|
ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool());
|
||||||
ui->sbScrollSpeed->setValue(Settings::value(Settings::Client::ScrollSpeed).toInt());
|
ui->sbScrollSpeed->setValue(Settings::value(Settings::Client::ScrollSpeed).toInt());
|
||||||
|
ui->cbGuiDebug->setChecked(Settings::value(Settings::Log::GuiDebug).toBool());
|
||||||
|
|
||||||
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
|
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
|
||||||
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
|
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,64 @@
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="7" column="0" colspan="4">
|
<item row="3" column="2">
|
||||||
|
<widget class="QLabel" name="lblLogLevel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Level</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QComboBox" name="comboLogLevel">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fatal</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Error</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Warning</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Note</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Info</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Debug</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Debug1</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Debug2</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="4">
|
||||||
<widget class="QWidget" name="widgetLogFilename" native="true">
|
<widget class="QWidget" name="widgetLogFilename" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
|
@ -505,7 +562,14 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="cbLogToFile">
|
||||||
|
<property name="text">
|
||||||
|
<string>Log to file</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
<spacer name="horizontalSpacer_5">
|
<spacer name="horizontalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
|
@ -518,71 +582,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="9" column="0" colspan="4">
|
||||||
<widget class="QCheckBox" name="cbLogToFile">
|
|
||||||
<property name="text">
|
|
||||||
<string>Log to file</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
|
||||||
<widget class="QComboBox" name="comboLogLevel">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fatal</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Error</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Warning</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Note</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Info</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Debug</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Debug1</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Debug2</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QLabel" name="lblLogLevel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Level</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="4">
|
|
||||||
<widget class="QLabel" name="lblDebugWarning">
|
<widget class="QLabel" name="lblDebugWarning">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Using a Debug log level may affect performance. Only use a Debug level if you are attempting to debug an issue or are gathering logs to submit with a bug report.</string>
|
<string>Using a Debug log level may affect performance. Only use a Debug level if you are attempting to debug an issue or are gathering logs to submit with a bug report.</string>
|
||||||
|
|
@ -592,6 +592,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="4">
|
||||||
|
<widget class="QCheckBox" name="cbGuiDebug">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable GUI debug messages</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LoggerTests.h"
|
#include "LoggerTests.h"
|
||||||
|
#include "common/Settings.h"
|
||||||
|
|
||||||
#include "gui/Logger.h"
|
#include "gui/Logger.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
|
|
||||||
using namespace deskflow::gui;
|
using namespace deskflow::gui;
|
||||||
|
|
||||||
|
void LoggerTests::initTestCase()
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
QVERIFY(dir.mkpath(m_settingsPath));
|
||||||
|
|
||||||
|
QFile oldSettings(m_settingsFile);
|
||||||
|
if (oldSettings.exists())
|
||||||
|
oldSettings.remove();
|
||||||
|
|
||||||
|
Settings::setSettingsFile(m_settingsFile);
|
||||||
|
}
|
||||||
|
|
||||||
void LoggerTests::newLine()
|
void LoggerTests::newLine()
|
||||||
{
|
{
|
||||||
Logger logger;
|
Logger logger;
|
||||||
|
|
@ -20,14 +35,12 @@ void LoggerTests::newLine()
|
||||||
QSignalSpy spy(&logger, &Logger::newLine);
|
QSignalSpy spy(&logger, &Logger::newLine);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
|
|
||||||
qputenv("DESKFLOW_GUI_DEBUG", "true");
|
Settings::setValue(Settings::Log::GuiDebug, true);
|
||||||
logger.loadEnvVars();
|
|
||||||
|
|
||||||
logger.handleMessage(QtDebugMsg, "stub", "test");
|
logger.handleMessage(QtDebugMsg, "stub", "test");
|
||||||
|
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QVERIFY(qvariant_cast<QString>(spy.takeFirst().at(0)).contains("test"));
|
QVERIFY(qvariant_cast<QString>(spy.takeFirst().at(0)).contains("test"));
|
||||||
qputenv("DESKFLOW_GUI_DEBUG", "");
|
Settings::setValue(Settings::Log::GuiDebug, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoggerTests::noNewLine()
|
void LoggerTests::noNewLine()
|
||||||
|
|
@ -38,12 +51,10 @@ void LoggerTests::noNewLine()
|
||||||
QSignalSpy spy(&logger, &Logger::newLine);
|
QSignalSpy spy(&logger, &Logger::newLine);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
|
|
||||||
qputenv("DESKFLOW_GUI_DEBUG", "false");
|
Settings::setValue(Settings::Log::GuiDebug, false);
|
||||||
logger.loadEnvVars();
|
|
||||||
logger.handleMessage(QtDebugMsg, "stub", "test");
|
logger.handleMessage(QtDebugMsg, "stub", "test");
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
QVERIFY(!newLineEmitted);
|
QVERIFY(!newLineEmitted);
|
||||||
qputenv("DESKFLOW_GUI_DEBUG", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(LoggerTests)
|
QTEST_MAIN(LoggerTests)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ class LoggerTests : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
// Test are run in order top to bottom
|
// Test are run in order top to bottom
|
||||||
|
void initTestCase();
|
||||||
void newLine();
|
void newLine();
|
||||||
void noNewLine();
|
void noNewLine();
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline static const QString m_settingsPath = QStringLiteral("tmp/test");
|
||||||
|
inline static const QString m_settingsFile = QStringLiteral("%1/Deskflow.conf").arg(m_settingsPath);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1235,6 +1235,10 @@ Al habilitar esta opción, se deshabilitará la interfaz gráfica de usuario (GU
|
||||||
<source>Force a language to be used for the GUI.</source>
|
<source>Force a language to be used for the GUI.</source>
|
||||||
<translation type="unfinished">Fuerza el uso de un idioma para la interfaz gráfica de usuario.</translation>
|
<translation type="unfinished">Fuerza el uso de un idioma para la interfaz gráfica de usuario.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Enable GUI debug messages</source>
|
||||||
|
<translation type="unfinished">Habilitar mensajes de depuración de la interfaz gráfica de usuario</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TlsCertificate</name>
|
<name>TlsCertificate</name>
|
||||||
|
|
|
||||||
|
|
@ -1235,6 +1235,10 @@ L'abilitazione di questa impostazione disabiliterà l'interfaccia graf
|
||||||
<source>Force a language to be used for the GUI.</source>
|
<source>Force a language to be used for the GUI.</source>
|
||||||
<translation>Forza l'utilizzo di una lingua per la GUI.</translation>
|
<translation>Forza l'utilizzo di una lingua per la GUI.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Enable GUI debug messages</source>
|
||||||
|
<translation>Abilita i messaggi di debug della GUI</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TlsCertificate</name>
|
<name>TlsCertificate</name>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue