diff --git a/autotests/testlog.cpp b/autotests/testlog.cpp --- a/autotests/testlog.cpp +++ b/autotests/testlog.cpp @@ -55,6 +55,7 @@ void TestLog::initTestCase() { + qputenv(KSCREEN_LOGGING, QByteArray("true")); } void TestLog::cleanupTestCase() @@ -85,6 +86,13 @@ qunsetenv(KSCREEN_LOGGING); log = Log::instance(); + QCOMPARE(log->enabled(), false); + QCOMPARE(log->logFile(), QString()); + + delete log; + qputenv(KSCREEN_LOGGING, QByteArray("truE")); + + log = Log::instance(); QCOMPARE(log->enabled(), true); QCOMPARE(log->logFile(), m_defaultLogFile); diff --git a/src/log.cpp b/src/log.cpp --- a/src/log.cpp +++ b/src/log.cpp @@ -57,7 +57,7 @@ { public: QString context; - bool enabled = true; + bool enabled = false; QString logFile; }; @@ -68,11 +68,13 @@ if (qEnvironmentVariableIsSet(logging_env)) { const QString logging_env_value = qgetenv(logging_env).constData(); - if (logging_env_value == QStringLiteral("0") || logging_env_value.toLower() == QStringLiteral("false")) { - d->enabled = false; - return; + if (logging_env_value != QStringLiteral("0") && logging_env_value.toLower() != QStringLiteral("false")) { + d->enabled = true; } } + if (!d->enabled) { + return; + } d->logFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kscreen/kscreen.log"; QLoggingCategory::setFilterRules("kscreen.*=true");