Changeset View
Changeset View
Standalone View
Standalone View
src/log.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
52 | return sInstance; | 52 | return sInstance; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | using namespace KScreen; | 55 | using namespace KScreen; | ||
56 | class Log::Private | 56 | class Log::Private | ||
57 | { | 57 | { | ||
58 | public: | 58 | public: | ||
59 | QString context; | 59 | QString context; | ||
60 | bool enabled = true; | 60 | bool enabled = false; | ||
61 | QString logFile; | 61 | QString logFile; | ||
62 | }; | 62 | }; | ||
63 | 63 | | |||
64 | Log::Log() : | 64 | Log::Log() : | ||
65 | d(new Private) | 65 | d(new Private) | ||
66 | { | 66 | { | ||
67 | const char* logging_env = "KSCREEN_LOGGING"; | 67 | const char* logging_env = "KSCREEN_LOGGING"; | ||
68 | 68 | | |||
69 | if (qEnvironmentVariableIsSet(logging_env)) { | 69 | if (qEnvironmentVariableIsSet(logging_env)) { | ||
70 | const QString logging_env_value = qgetenv(logging_env).constData(); | 70 | const QString logging_env_value = qgetenv(logging_env).constData(); | ||
71 | if (logging_env_value == QStringLiteral("0") || logging_env_value.toLower() == QStringLiteral("false")) { | 71 | if (logging_env_value != QStringLiteral("0") && logging_env_value.toLower() != QStringLiteral("false")) { | ||
72 | d->enabled = false; | 72 | d->enabled = true; | ||
73 | return; | 73 | } | ||
74 | } | 74 | } | ||
75 | if (!d->enabled) { | ||||
76 | return; | ||||
75 | } | 77 | } | ||
76 | d->logFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kscreen/kscreen.log"; | 78 | d->logFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kscreen/kscreen.log"; | ||
77 | 79 | | |||
78 | QLoggingCategory::setFilterRules("kscreen.*=true"); | 80 | QLoggingCategory::setFilterRules("kscreen.*=true"); | ||
79 | QFileInfo fi(d->logFile); | 81 | QFileInfo fi(d->logFile); | ||
80 | if (!QDir().mkpath(fi.absolutePath())) { | 82 | if (!QDir().mkpath(fi.absolutePath())) { | ||
81 | qWarning() << "Failed to create logging dir" << fi.absolutePath(); | 83 | qWarning() << "Failed to create logging dir" << fi.absolutePath(); | ||
82 | } | 84 | } | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |