summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
commitda2b049e248c1ad7efeb53685158a205335e4e36 (patch)
tree1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /examples/dummyresource/resourcefactory.cpp
parent9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff)
downloadsink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz
sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip
A new debug system.
Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names.
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r--examples/dummyresource/resourcefactory.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index 21a76ad..0f7463f 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -48,6 +48,8 @@
48#define ENTITY_TYPE_MAIL "mail" 48#define ENTITY_TYPE_MAIL "mail"
49#define ENTITY_TYPE_FOLDER "folder" 49#define ENTITY_TYPE_FOLDER "folder"
50 50
51SINK_DEBUG_AREA("dummyresource")
52
51class DummySynchronizer : public Sink::Synchronizer { 53class DummySynchronizer : public Sink::Synchronizer {
52 public: 54 public:
53 55
@@ -105,12 +107,12 @@ class DummySynchronizer : public Sink::Synchronizer {
105 auto entity = createEntity(remoteId, it.value()); 107 auto entity = createEntity(remoteId, it.value());
106 createOrModify(bufferType, remoteId, *entity); 108 createOrModify(bufferType, remoteId, *entity);
107 } 109 }
108 Trace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed()); 110 SinkTrace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed());
109 } 111 }
110 112
111 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE 113 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
112 { 114 {
113 Log() << " Synchronizing with the source"; 115 SinkLog() << " Synchronizing with the source";
114 return KAsync::start<void>([this]() { 116 return KAsync::start<void>([this]() {
115 synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) { 117 synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) {
116 return createEvent(ridBuffer, data); 118 return createEvent(ridBuffer, data);
@@ -121,7 +123,7 @@ class DummySynchronizer : public Sink::Synchronizer {
121 synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) { 123 synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) {
122 return createFolder(ridBuffer, data); 124 return createFolder(ridBuffer, data);
123 }); 125 });
124 Log() << "Done Synchronizing"; 126 SinkLog() << "Done Synchronizing";
125 }); 127 });
126 } 128 }
127 129
@@ -147,7 +149,7 @@ DummyResource::~DummyResource()
147 149
148KAsync::Job<void> DummyResource::synchronizeWithSource() 150KAsync::Job<void> DummyResource::synchronizeWithSource()
149{ 151{
150 Trace() << "Synchronize with source and sending a notification about it"; 152 SinkTrace() << "Synchronize with source and sending a notification about it";
151 Sink::Notification n; 153 Sink::Notification n;
152 n.id = "connected"; 154 n.id = "connected";
153 n.type = Sink::Notification::Status; 155 n.type = Sink::Notification::Status;
@@ -160,7 +162,7 @@ KAsync::Job<void> DummyResource::synchronizeWithSource()
160KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) 162KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue)
161{ 163{
162 164
163 Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; 165 SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue;
164 if (property == "testInspection") { 166 if (property == "testInspection") {
165 if (expectedValue.toBool()) { 167 if (expectedValue.toBool()) {
166 //Success 168 //Success