refactor: Logger store a local copy of the used setting value for guiDebug, update it went the settings have changed

This commit is contained in:
sithlord48
2025-11-13 10:43:24 -05:00
committed by Chris Rizzitello
parent ec9f7efcff
commit ddcd2f0ff1
2 changed files with 23 additions and 3 deletions

View File

@ -61,7 +61,7 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
auto out = stdout;
switch (mutatedType) {
case QtDebugMsg:
if (!Settings::value(Settings::Log::GuiDebug).toBool())
if (!m_guiDebug)
return;
typeString = "DEBUG";
break;
@ -86,4 +86,22 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
Q_EMIT newLine(logLine);
}
Logger::Logger()
{
m_guiDebug = Settings::value(Settings::Log::GuiDebug).toBool();
connect(Settings::instance(), &Settings::settingsChanged, this, &Logger::settingChanged);
}
Logger::~Logger()
{
disconnect(Settings::instance(), &Settings::settingsChanged, this, &Logger::settingChanged);
}
void Logger::settingChanged(const QString &key)
{
if (key != Settings::Log::GuiDebug)
return;
m_guiDebug = Settings::value(Settings::Log::GuiDebug).toBool();
}
} // namespace deskflow::gui

View File

@ -27,8 +27,10 @@ Q_SIGNALS:
void newLine(const QString &line);
private:
explicit Logger() = default;
~Logger() = default;
explicit Logger();
~Logger();
void settingChanged(const QString &key);
bool m_guiDebug = false;
};
} // namespace deskflow::gui