diff options
Diffstat (limited to 'common/log.cpp')
-rw-r--r-- | common/log.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/common/log.cpp b/common/log.cpp index 045b3cc..4024545 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -12,12 +12,17 @@ | |||
12 | #include <memory> | 12 | #include <memory> |
13 | #include <atomic> | 13 | #include <atomic> |
14 | #include <definitions.h> | 14 | #include <definitions.h> |
15 | #include <QThreadStorage> | ||
15 | 16 | ||
16 | using namespace Sink::Log; | 17 | using namespace Sink::Log; |
17 | 18 | ||
18 | static QSharedPointer<QSettings> config() | 19 | QThreadStorage<QSharedPointer<QSettings>> sSettings; |
20 | static QSettings &config() | ||
19 | { | 21 | { |
20 | return QSharedPointer<QSettings>::create(Sink::configLocation() + "/log.ini", QSettings::IniFormat); | 22 | if (!sSettings.hasLocalData()) { |
23 | sSettings.setLocalData(QSharedPointer<QSettings>::create(Sink::configLocation() + "/log.ini", QSettings::IniFormat)); | ||
24 | } | ||
25 | return *sSettings.localData(); | ||
21 | } | 26 | } |
22 | 27 | ||
23 | static QByteArray sPrimaryComponent; | 28 | static QByteArray sPrimaryComponent; |
@@ -173,22 +178,22 @@ DebugLevel Sink::Log::debugLevelFromName(const QByteArray &name) | |||
173 | 178 | ||
174 | void Sink::Log::setDebugOutputLevel(DebugLevel debugLevel) | 179 | void Sink::Log::setDebugOutputLevel(DebugLevel debugLevel) |
175 | { | 180 | { |
176 | config()->setValue("level", debugLevel); | 181 | config().setValue("level", debugLevel); |
177 | } | 182 | } |
178 | 183 | ||
179 | Sink::Log::DebugLevel Sink::Log::debugOutputLevel() | 184 | Sink::Log::DebugLevel Sink::Log::debugOutputLevel() |
180 | { | 185 | { |
181 | return static_cast<Sink::Log::DebugLevel>(config()->value("level", Sink::Log::Log).toInt()); | 186 | return static_cast<Sink::Log::DebugLevel>(config().value("level", Sink::Log::Log).toInt()); |
182 | } | 187 | } |
183 | 188 | ||
184 | void Sink::Log::setDebugOutputFilter(FilterType type, const QByteArrayList &filter) | 189 | void Sink::Log::setDebugOutputFilter(FilterType type, const QByteArrayList &filter) |
185 | { | 190 | { |
186 | switch (type) { | 191 | switch (type) { |
187 | case ApplicationName: | 192 | case ApplicationName: |
188 | config()->setValue("applicationfilter", QVariant::fromValue(filter)); | 193 | config().setValue("applicationfilter", QVariant::fromValue(filter)); |
189 | break; | 194 | break; |
190 | case Area: | 195 | case Area: |
191 | config()->setValue("areafilter", QVariant::fromValue(filter)); | 196 | config().setValue("areafilter", QVariant::fromValue(filter)); |
192 | break; | 197 | break; |
193 | } | 198 | } |
194 | } | 199 | } |
@@ -197,9 +202,9 @@ QByteArrayList Sink::Log::debugOutputFilter(FilterType type) | |||
197 | { | 202 | { |
198 | switch (type) { | 203 | switch (type) { |
199 | case ApplicationName: | 204 | case ApplicationName: |
200 | return config()->value("applicationfilter").value<QByteArrayList>(); | 205 | return config().value("applicationfilter").value<QByteArrayList>(); |
201 | case Area: | 206 | case Area: |
202 | return config()->value("areafilter").value<QByteArrayList>(); | 207 | return config().value("areafilter").value<QByteArrayList>(); |
203 | default: | 208 | default: |
204 | return QByteArrayList(); | 209 | return QByteArrayList(); |
205 | } | 210 | } |
@@ -207,12 +212,12 @@ QByteArrayList Sink::Log::debugOutputFilter(FilterType type) | |||
207 | 212 | ||
208 | void Sink::Log::setDebugOutputFields(const QByteArrayList &output) | 213 | void Sink::Log::setDebugOutputFields(const QByteArrayList &output) |
209 | { | 214 | { |
210 | config()->setValue("outputfields", QVariant::fromValue(output)); | 215 | config().setValue("outputfields", QVariant::fromValue(output)); |
211 | } | 216 | } |
212 | 217 | ||
213 | QByteArrayList Sink::Log::debugOutputFields() | 218 | QByteArrayList Sink::Log::debugOutputFields() |
214 | { | 219 | { |
215 | return config()->value("outputfields").value<QByteArrayList>(); | 220 | return config().value("outputfields").value<QByteArrayList>(); |
216 | } | 221 | } |
217 | 222 | ||
218 | static QByteArray getProgramName() | 223 | static QByteArray getProgramName() |