From 87d70a4c3c52a9b6bb5c905bf02ec526f01f859f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 23 Dec 2016 12:57:46 +0100 Subject: Better debug output --- common/log.h | 3 +++ common/store.cpp | 12 ++++++++++-- 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 { QByteArray name; Context subContext(const QByteArray &sub) const { + if (name.isEmpty()) { + return Context{sub}; + } return Context{name + "." + sub}; } }; 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::Ptr, typenam return qMakePair(aggregatingEmitter, ResultEmitter::Ptr{}); } +static Log::Context getQueryContext(const Sink::Query &query, const QByteArray &type) +{ + if (!query.id().isEmpty()) { + return Log::Context{"query." + type + "." + query.id()}; + } + return Log::Context{"query." + type}; +} + template QSharedPointer Store::loadModel(const Query &query) { - Log::Context ctx{query.id()}; + auto ctx = getQueryContext(query, ApplicationDomain::getTypeName()); auto model = QSharedPointer>::create(query, query.requestedProperties, ctx); //* Client defines lifetime of model @@ -338,7 +346,7 @@ QList Store::read(const Sink::Query &query_) auto query = query_; query.setFlags(Query::SynchronousQuery); - Log::Context ctx{query.id()}; + auto ctx = getQueryContext(query, ApplicationDomain::getTypeName()); QList list; -- cgit v1.2.3