Settings: add option to disable logging to disk

This commit is contained in:
tobtoht 2022-03-03 16:22:59 +01:00
parent f9019cb1b0
commit a8d33099a2
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
5 changed files with 25 additions and 2 deletions

View 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();

View file

@ -211,6 +211,13 @@
</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">

View 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();

View 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"}},

View file

@ -24,6 +24,7 @@ public:
firstRun,
warnOnStagenet,
warnOnTestnet,
logLevel,
homeWidget,
donateBeg,
@ -72,6 +73,7 @@ public:
multiBroadcast,
warnOnExternalLink,
hideBalance,
disableLogging,
blockExplorer,
redditFrontend,