]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Settings: add option to disable logging to disk
authortobtoht <thotbot@protonmail.com>
Thu, 3 Mar 2022 15:22:59 +0000 (16:22 +0100)
committertobtoht <thotbot@protonmail.com>
Thu, 3 Mar 2022 15:22:59 +0000 (16:22 +0100)
src/SettingsDialog.cpp
src/SettingsDialog.ui
src/main.cpp
src/utils/config.cpp
src/utils/config.h

index bb4ffe17e0aea8a6e1d463242f9af01d636c44b4..18c27ea2a8d8e799eb2df3f346dab587171810f8 100644 (file)
@@ -27,6 +27,10 @@ Settings::Settings(QSharedPointer<AppContext> ctx, QWidget *parent)
         config()->set(Config::hideBalance, toggled);
         m_ctx->updateBalance();
     });
+    connect(ui->checkBox_disableLogging, &QCheckBox::toggled, [this](bool toggled){
+       config()->set(Config::disableLogging, toggled);
+       WalletManager::instance()->setLogLevel(toggled ? -1 : config()->get(Config::logLevel).toInt());
+    });
 
     connect(ui->closeButton, &QDialogButtonBox::accepted, this, &Settings::close);
 
@@ -39,6 +43,7 @@ Settings::Settings(QSharedPointer<AppContext> ctx, QWidget *parent)
     ui->checkBox_multiBroadcast->setChecked(config()->get(Config::multiBroadcast).toBool());
     ui->checkBox_externalLink->setChecked(config()->get(Config::warnOnExternalLink).toBool());
     ui->checkBox_hideBalance->setChecked(config()->get(Config::hideBalance).toBool());
+    ui->checkBox_disableLogging->setChecked(config()->get(Config::disableLogging).toBool());
 
     // setup comboboxes
     this->setupSkinCombobox();
index 2a2e1521b0db045eaded198747e0cbd2fe4bca37..93b437f3e01785e0a0a4ad6dc58f1c2d01981c29 100644 (file)
          </property>
         </widget>
        </item>
+       <item>
+        <widget class="QCheckBox" name="checkBox_disableLogging">
+         <property name="text">
+          <string>Do not write log files to disk</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab_node">
index 531fe9015af1a7b414da82ea32b31a73e2a1a635..a534ad1a044f211f192bdc8c42cbc846037ec57d 100644 (file)
@@ -143,11 +143,18 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
 
     bool logLevelFromEnv;
     int logLevel = qEnvironmentVariableIntValue("MONERO_LOG_LEVEL", &logLevelFromEnv);
+    if (!logLevelFromEnv) {
+        logLevel = 0;
+    }
+    config()->set(Config::logLevel, logLevel);
 
-    if (parser.isSet("quiet"))
+    if (parser.isSet("quiet") || config()->get(Config::disableLogging).toBool()) {
+        qWarning() << "Logging is disabled";
         WalletManager::instance()->setLogLevel(-1);
-    else if (logLevelFromEnv && logLevel >= 0 && logLevel <= Monero::WalletManagerFactory::LogLevel_Max)
+    }
+    else if (logLevelFromEnv && logLevel >= 0 && logLevel <= Monero::WalletManagerFactory::LogLevel_Max) {
         Monero::WalletManagerFactory::setLogLevel(logLevel);
+    }
 
     // Setup wallet directory
     QString walletDir = config()->get(Config::walletDirectory).toString();
index 8c693fa22cb8a1da5ea85e7f7c855bbac6f27a2f..8c39d77bc12300211ec41f6852a8cde3804b84c5 100644 (file)
@@ -20,6 +20,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
         {Config::firstRun, {QS("firstRun"), true}},
         {Config::warnOnStagenet,{QS("warnOnStagenet"), true}},
         {Config::warnOnTestnet,{QS("warnOnTestnet"), true}},
+        {Config::logLevel,{QS("logLevel"), 0}},
 
         {Config::homeWidget,{QS("homeWidget"), "ccs"}},
         {Config::donateBeg,{QS("donateBeg"), 1}},
@@ -68,6 +69,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
         {Config::multiBroadcast, {QS("multiBroadcast"), true}},
         {Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}},
         {Config::hideBalance, {QS("hideBalance"), false}},
+        {Config::disableLogging, {QS("disableLogging"), false}},
 
         {Config::blockExplorer,{QS("blockExplorer"), "exploremonero.com"}},
         {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
index f0fd70ea641723c956fa5487a746c38f7009a31a..3d1f19f43be7b124ed96b95bd24e8eb485cbc43c 100644 (file)
@@ -24,6 +24,7 @@ public:
         firstRun,
         warnOnStagenet,
         warnOnTestnet,
+        logLevel,
 
         homeWidget,
         donateBeg,
@@ -72,6 +73,7 @@ public:
         multiBroadcast,
         warnOnExternalLink,
         hideBalance,
+        disableLogging,
 
         blockExplorer,
         redditFrontend,