summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/log.h3
-rw-r--r--common/store.cpp12
2 files changed, 13 insertions, 2 deletions
diff --git a/common/log.h b/common/log.h
index fc2a3ed..d1776ac 100644
--- a/common/log.h
+++ b/common/log.h
@@ -13,6 +13,9 @@ struct Context {
13 13
14 QByteArray name; 14 QByteArray name;
15 Context subContext(const QByteArray &sub) const { 15 Context subContext(const QByteArray &sub) const {
16 if (name.isEmpty()) {
17 return Context{sub};
18 }
16 return Context{name + "." + sub}; 19 return Context{name + "." + sub};
17 } 20 }
18}; 21};
diff --git a/common/store.cpp b/common/store.cpp
index ac1124a..c461157 100644
--- a/common/store.cpp
+++ b/common/store.cpp
@@ -120,10 +120,18 @@ QPair<typename AggregatingResultEmitter<typename DomainType::Ptr>::Ptr, typenam
120 return qMakePair(aggregatingEmitter, ResultEmitter<typename ApplicationDomain::SinkResource::Ptr>::Ptr{}); 120 return qMakePair(aggregatingEmitter, ResultEmitter<typename ApplicationDomain::SinkResource::Ptr>::Ptr{});
121} 121}
122 122
123static Log::Context getQueryContext(const Sink::Query &query, const QByteArray &type)
124{
125 if (!query.id().isEmpty()) {
126 return Log::Context{"query." + type + "." + query.id()};
127 }
128 return Log::Context{"query." + type};
129}
130
123template <class DomainType> 131template <class DomainType>
124QSharedPointer<QAbstractItemModel> Store::loadModel(const Query &query) 132QSharedPointer<QAbstractItemModel> Store::loadModel(const Query &query)
125{ 133{
126 Log::Context ctx{query.id()}; 134 auto ctx = getQueryContext(query, ApplicationDomain::getTypeName<DomainType>());
127 auto model = QSharedPointer<ModelResult<DomainType, typename DomainType::Ptr>>::create(query, query.requestedProperties, ctx); 135 auto model = QSharedPointer<ModelResult<DomainType, typename DomainType::Ptr>>::create(query, query.requestedProperties, ctx);
128 136
129 //* Client defines lifetime of model 137 //* Client defines lifetime of model
@@ -338,7 +346,7 @@ QList<DomainType> Store::read(const Sink::Query &query_)
338 auto query = query_; 346 auto query = query_;
339 query.setFlags(Query::SynchronousQuery); 347 query.setFlags(Query::SynchronousQuery);
340 348
341 Log::Context ctx{query.id()}; 349 auto ctx = getQueryContext(query, ApplicationDomain::getTypeName<DomainType>());
342 350
343 QList<DomainType> list; 351 QList<DomainType> list;
344 352