Added activation and deactivation of logging without restarting the application

This commit is contained in:
vladimir.kuznetsov 2022-12-28 06:52:02 +03:00
parent ce4ca5c4d5
commit 195663c6e3
3 changed files with 23 additions and 0 deletions

View file

@ -80,6 +80,14 @@ bool Debug::init()
return true;
}
void Debug::deInit()
{
qInstallMessageHandler(0);
qSetMessagePattern("%{message}");
m_textStream.setDevice(nullptr);
m_file.close();
}
QString Debug::userLogsDir()
{
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/log";

View file

@ -23,6 +23,7 @@ public:
static bool init();
static void deInit();
static bool openLogsFolder();
static bool openServiceLogsFolder();
static QString appLogFileNamePath();

View file

@ -3,6 +3,7 @@
#include "utilities.h"
#include "containers/containers_defs.h"
#include "debug.h"
const char Settings::cloudFlareNs1[] = "1.1.1.1";
const char Settings::cloudFlareNs2[] = "1.0.0.1";
@ -206,6 +207,19 @@ QString Settings::nextAvailableServerName() const
return tr("Server") + " " + QString::number(i);
}
void Settings::setSaveLogs(bool enabled)
{
m_settings.setValue("Conf/saveLogs", enabled);
if (!isSaveLogs()) {
Debug::deInit();
} else {
if (!Debug::init()) {
qWarning() << "Initialization of debug subsystem failed";
}
}
emit updateVpnPage();
}
QString Settings::routeModeString(RouteMode mode) const
{
switch (mode) {