From b2ad8f785e801a35cadf254d827f56d648be510c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 22 Dec 2016 18:22:39 +0100 Subject: Introduced Log::Context To have hierarchical debug output we have to pass around something at run-time, there is no reasonable alternative. Log::Context provides the identifier to do just that and largely replaces the debug component idea. --- tests/clientapitest.cpp | 18 +++++++++--------- tests/databasepopulationandfacadequerybenchmark.cpp | 2 +- tests/mailquerybenchmark.cpp | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index d2fb747..544b981 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp @@ -53,28 +53,28 @@ public: { return KAsync::null(); }; - QPair, typename Sink::ResultEmitter::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE + QPair, typename Sink::ResultEmitter::Ptr> load(const Sink::Query &query, const Sink::Log::Context &ctx) Q_DECL_OVERRIDE { auto resultProvider = new Sink::ResultProvider(); - resultProvider->onDone([resultProvider]() { - SinkTrace() << "Result provider is done"; + resultProvider->onDone([resultProvider,ctx]() { + SinkTraceCtx(ctx) << "Result provider is done"; delete resultProvider; }); // We have to do it this way, otherwise we're not setting the fetcher right auto emitter = resultProvider->emitter(); - resultProvider->setFetcher([query, resultProvider, this](const typename T::Ptr &parent) { + resultProvider->setFetcher([query, resultProvider, this, ctx](const typename T::Ptr &parent) { if (parent) { - SinkTrace() << "Running the fetcher " << parent->identifier(); + SinkTraceCtx(ctx) << "Running the fetcher " << parent->identifier(); } else { - SinkTrace() << "Running the fetcher."; + SinkTraceCtx(ctx) << "Running the fetcher."; } - SinkTrace() << "-------------------------."; + SinkTraceCtx(ctx) << "-------------------------."; for (const auto &res : results) { - qDebug() << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); + SinkTraceCtx(ctx) << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); auto parentProperty = res->getProperty("parent").toByteArray(); if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { - qDebug() << "Found a hit" << res->identifier(); + SinkTraceCtx(ctx) << "Found a hit" << res->identifier(); resultProvider->add(res); } } diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp index 6bd2051..48c4738 100644 --- a/tests/databasepopulationandfacadequerybenchmark.cpp +++ b/tests/databasepopulationandfacadequerybenchmark.cpp @@ -106,7 +106,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject context.mResourceAccess = resourceAccess; TestResourceFacade facade(context); - auto ret = facade.load(query); + auto ret = facade.load(query, Sink::Log::Context{"benchmark"}); ret.first.exec().waitForFinished(); auto emitter = ret.second; QList list; diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index d3598b2..e55e744 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp @@ -84,7 +84,6 @@ class MailQueryBenchmark : public QObject { const auto startingRss = getCurrentRSS(); - // Benchmark QTime time; time.start(); @@ -93,7 +92,7 @@ class MailQueryBenchmark : public QObject context.mResourceAccess = QSharedPointer::create(); TestMailResourceFacade facade(context); - auto ret = facade.load(query); + auto ret = facade.load(query, Sink::Log::Context{"benchmark"}); ret.first.exec().waitForFinished(); auto emitter = ret.second; QList list; -- cgit v1.2.3