aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/settings
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2017-08-28 14:20:15 +0200
committerMitch Curtis <mitch.curtis@qt.io>2017-08-29 08:40:32 +0000
commit457c5bcb148e8ff13141e086b905f47d8b9ae03c (patch)
tree96ad7f7486e6c55d87248e3785ee2183a178a509 /src/imports/settings
parenta717ecfadfbc4785eb5c33d3d6b5b1219d772067 (diff)
QQmlSettings: use categorised logging
This makes it possible to e.g. easily see where the settings are saved to without having to define the macro and recompile the code. Change-Id: I9c65e6702929d86b1e439f3d836c881b3ebad14f Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/imports/settings')
-rw-r--r--src/imports/settings/qqmlsettings.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp
index df67c04654..ed2f58e7c1 100644
--- a/src/imports/settings/qqmlsettings.cpp
+++ b/src/imports/settings/qqmlsettings.cpp
@@ -39,6 +39,7 @@
#include "qqmlsettings_p.h"
#include <qcoreevent.h>
+#include <qloggingcategory.h>
#include <qsettings.h>
#include <qpointer.h>
#include <qjsvalue.h>
@@ -222,7 +223,7 @@ QT_BEGIN_NAMESPACE
\sa QSettings
*/
-// #define SETTINGS_DEBUG
+Q_LOGGING_CATEGORY(lcSettings, "qt.labs.settings")
static const int settingsWriteDelay = 500;
@@ -273,9 +274,7 @@ QSettings *QQmlSettingsPrivate::instance() const
void QQmlSettingsPrivate::init()
{
if (!initialized) {
-#ifdef SETTINGS_DEBUG
- qDebug() << "QQmlSettings: stored at" << instance()->fileName();
-#endif
+ qCDebug(lcSettings) << "QQmlSettings: stored at" << instance()->fileName();
load();
initialized = true;
}
@@ -303,9 +302,7 @@ void QQmlSettingsPrivate::load()
if (!currentValue.isNull() && (!previousValue.isValid()
|| (currentValue.canConvert(previousValue.type()) && previousValue != currentValue))) {
property.write(q, currentValue);
-#ifdef SETTINGS_DEBUG
- qDebug() << "QQmlSettings: load" << property.name() << "setting:" << currentValue << "default:" << previousValue;
-#endif
+ qCDebug(lcSettings) << "QQmlSettings: load" << property.name() << "setting:" << currentValue << "default:" << previousValue;
}
// ensure that a non-existent setting gets written
@@ -326,9 +323,7 @@ void QQmlSettingsPrivate::store()
QHash<const char *, QVariant>::const_iterator it = changedProperties.constBegin();
while (it != changedProperties.constEnd()) {
instance()->setValue(it.key(), it.value());
-#ifdef SETTINGS_DEBUG
- qDebug() << "QQmlSettings: store" << it.key() << ":" << it.value();
-#endif
+ qCDebug(lcSettings) << "QQmlSettings: store" << it.key() << ":" << it.value();
++it;
}
changedProperties.clear();
@@ -344,9 +339,7 @@ void QQmlSettingsPrivate::_q_propertyChanged()
const QMetaProperty &property = mo->property(i);
const QVariant value = readProperty(property);
changedProperties.insert(property.name(), value);
-#ifdef SETTINGS_DEBUG
- qDebug() << "QQmlSettings: cache" << property.name() << ":" << value;
-#endif
+ qCDebug(lcSettings) << "QQmlSettings: cache" << property.name() << ":" << value;
}
if (timerId != 0)
q->killTimer(timerId);