summaryrefslogtreecommitdiffstats
path: root/common/resourcefacade.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 /common/resourcefacade.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 'common/resourcefacade.cpp')
-rw-r--r--common/resourcefacade.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp
index 0bcc6b9..bdb5841 100644
--- a/common/resourcefacade.cpp
+++ b/common/resourcefacade.cpp
@@ -28,6 +28,8 @@
28 28
29using namespace Sink; 29using namespace Sink;
30 30
31SINK_DEBUG_AREA("ResourceFacade")
32
31template<typename DomainType> 33template<typename DomainType>
32ConfigNotifier LocalStorageFacade<DomainType>::sConfigNotifier; 34ConfigNotifier LocalStorageFacade<DomainType>::sConfigNotifier;
33 35
@@ -67,7 +69,7 @@ LocalStorageQueryRunner<DomainType>::LocalStorageQueryRunner(const Query &query,
67 const auto type = entries.value(res); 69 const auto type = entries.value(res);
68 70
69 if (query.propertyFilter.contains("type") && query.propertyFilter.value("type").value.toByteArray() != type) { 71 if (query.propertyFilter.contains("type") && query.propertyFilter.value("type").value.toByteArray() != type) {
70 Trace() << "Skipping due to type."; 72 SinkTrace() << "Skipping due to type.";
71 continue; 73 continue;
72 } 74 }
73 if (!query.ids.isEmpty() && !query.ids.contains(res)) { 75 if (!query.ids.isEmpty() && !query.ids.contains(res)) {
@@ -75,10 +77,10 @@ LocalStorageQueryRunner<DomainType>::LocalStorageQueryRunner(const Query &query,
75 } 77 }
76 const auto configurationValues = mConfigStore.get(res); 78 const auto configurationValues = mConfigStore.get(res);
77 if (!matchesFilter(query.propertyFilter, configurationValues)){ 79 if (!matchesFilter(query.propertyFilter, configurationValues)){
78 Trace() << "Skipping due to filter."; 80 SinkTrace() << "Skipping due to filter.";
79 continue; 81 continue;
80 } 82 }
81 Trace() << "Found match " << res; 83 SinkTrace() << "Found match " << res;
82 auto entity = readFromConfig<DomainType>(mConfigStore, res, type); 84 auto entity = readFromConfig<DomainType>(mConfigStore, res, type);
83 updateStatus(*entity); 85 updateStatus(*entity);
84 mResultProvider->add(entity); 86 mResultProvider->add(entity);
@@ -137,7 +139,7 @@ void LocalStorageQueryRunner<DomainType>::setStatusUpdater(const std::function<v
137template<typename DomainType> 139template<typename DomainType>
138void LocalStorageQueryRunner<DomainType>::statusChanged(const QByteArray &identifier) 140void LocalStorageQueryRunner<DomainType>::statusChanged(const QByteArray &identifier)
139{ 141{
140 Trace() << "Status changed " << identifier; 142 SinkTrace() << "Status changed " << identifier;
141 auto entity = readFromConfig<DomainType>(mConfigStore, identifier, ApplicationDomain::getTypeName<DomainType>()); 143 auto entity = readFromConfig<DomainType>(mConfigStore, identifier, ApplicationDomain::getTypeName<DomainType>());
142 updateStatus(*entity); 144 updateStatus(*entity);
143 mResultProvider->modify(entity); 145 mResultProvider->modify(entity);
@@ -195,7 +197,7 @@ KAsync::Job<void> LocalStorageFacade<DomainType>::modify(const DomainType &domai
195 return KAsync::start<void>([domainObject, this]() { 197 return KAsync::start<void>([domainObject, this]() {
196 const QByteArray identifier = domainObject.identifier(); 198 const QByteArray identifier = domainObject.identifier();
197 if (identifier.isEmpty()) { 199 if (identifier.isEmpty()) {
198 Warning() << "We need an \"identifier\" property to identify the entity to configure."; 200 SinkWarning() << "We need an \"identifier\" property to identify the entity to configure.";
199 return; 201 return;
200 } 202 }
201 auto changedProperties = domainObject.changedProperties(); 203 auto changedProperties = domainObject.changedProperties();
@@ -221,10 +223,10 @@ KAsync::Job<void> LocalStorageFacade<DomainType>::remove(const DomainType &domai
221 return KAsync::start<void>([domainObject, this]() { 223 return KAsync::start<void>([domainObject, this]() {
222 const QByteArray identifier = domainObject.identifier(); 224 const QByteArray identifier = domainObject.identifier();
223 if (identifier.isEmpty()) { 225 if (identifier.isEmpty()) {
224 Warning() << "We need an \"identifier\" property to identify the entity to configure"; 226 SinkWarning() << "We need an \"identifier\" property to identify the entity to configure";
225 return; 227 return;
226 } 228 }
227 Trace() << "Removing: " << identifier; 229 SinkTrace() << "Removing: " << identifier;
228 mConfigStore.remove(identifier); 230 mConfigStore.remove(identifier);
229 sConfigNotifier.remove(QSharedPointer<DomainType>::create(domainObject)); 231 sConfigNotifier.remove(QSharedPointer<DomainType>::create(domainObject));
230 }); 232 });
@@ -259,7 +261,7 @@ QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename ApplicationDomain
259 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource.identifier(), ResourceConfig::getResourceType(resource.identifier())); 261 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource.identifier(), ResourceConfig::getResourceType(resource.identifier()));
260 if (!monitoredResources->contains(resource.identifier())) { 262 if (!monitoredResources->contains(resource.identifier())) {
261 auto ret = QObject::connect(resourceAccess.data(), &ResourceAccess::notification, runner->guard(), [resource, runner, resourceAccess](const Notification &notification) { 263 auto ret = QObject::connect(resourceAccess.data(), &ResourceAccess::notification, runner->guard(), [resource, runner, resourceAccess](const Notification &notification) {
262 Trace() << "Received notification in facade: " << notification.type; 264 SinkTrace() << "Received notification in facade: " << notification.type;
263 if (notification.type == Notification::Status) { 265 if (notification.type == Notification::Status) {
264 runner->statusChanged(resource.identifier()); 266 runner->statusChanged(resource.identifier());
265 } 267 }