diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-22 18:22:39 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-22 18:22:39 +0100 |
commit | b2ad8f785e801a35cadf254d827f56d648be510c (patch) | |
tree | 4eeb1e3eefb02c40dac40469c0fae5ad91feb3e3 /tests | |
parent | 1fe8664ec74165fc3f250098609ea0e049e3adc8 (diff) | |
download | sink-b2ad8f785e801a35cadf254d827f56d648be510c.tar.gz sink-b2ad8f785e801a35cadf254d827f56d648be510c.zip |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clientapitest.cpp | 18 | ||||
-rw-r--r-- | tests/databasepopulationandfacadequerybenchmark.cpp | 2 | ||||
-rw-r--r-- | tests/mailquerybenchmark.cpp | 3 |
3 files changed, 11 insertions, 12 deletions
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: | |||
53 | { | 53 | { |
54 | return KAsync::null<void>(); | 54 | return KAsync::null<void>(); |
55 | }; | 55 | }; |
56 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename T::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE | 56 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename T::Ptr>::Ptr> load(const Sink::Query &query, const Sink::Log::Context &ctx) Q_DECL_OVERRIDE |
57 | { | 57 | { |
58 | auto resultProvider = new Sink::ResultProvider<typename T::Ptr>(); | 58 | auto resultProvider = new Sink::ResultProvider<typename T::Ptr>(); |
59 | resultProvider->onDone([resultProvider]() { | 59 | resultProvider->onDone([resultProvider,ctx]() { |
60 | SinkTrace() << "Result provider is done"; | 60 | SinkTraceCtx(ctx) << "Result provider is done"; |
61 | delete resultProvider; | 61 | delete resultProvider; |
62 | }); | 62 | }); |
63 | // We have to do it this way, otherwise we're not setting the fetcher right | 63 | // We have to do it this way, otherwise we're not setting the fetcher right |
64 | auto emitter = resultProvider->emitter(); | 64 | auto emitter = resultProvider->emitter(); |
65 | 65 | ||
66 | resultProvider->setFetcher([query, resultProvider, this](const typename T::Ptr &parent) { | 66 | resultProvider->setFetcher([query, resultProvider, this, ctx](const typename T::Ptr &parent) { |
67 | if (parent) { | 67 | if (parent) { |
68 | SinkTrace() << "Running the fetcher " << parent->identifier(); | 68 | SinkTraceCtx(ctx) << "Running the fetcher " << parent->identifier(); |
69 | } else { | 69 | } else { |
70 | SinkTrace() << "Running the fetcher."; | 70 | SinkTraceCtx(ctx) << "Running the fetcher."; |
71 | } | 71 | } |
72 | SinkTrace() << "-------------------------."; | 72 | SinkTraceCtx(ctx) << "-------------------------."; |
73 | for (const auto &res : results) { | 73 | for (const auto &res : results) { |
74 | qDebug() << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); | 74 | SinkTraceCtx(ctx) << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); |
75 | auto parentProperty = res->getProperty("parent").toByteArray(); | 75 | auto parentProperty = res->getProperty("parent").toByteArray(); |
76 | if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { | 76 | if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { |
77 | qDebug() << "Found a hit" << res->identifier(); | 77 | SinkTraceCtx(ctx) << "Found a hit" << res->identifier(); |
78 | resultProvider->add(res); | 78 | resultProvider->add(res); |
79 | } | 79 | } |
80 | } | 80 | } |
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 | |||
106 | context.mResourceAccess = resourceAccess; | 106 | context.mResourceAccess = resourceAccess; |
107 | TestResourceFacade facade(context); | 107 | TestResourceFacade facade(context); |
108 | 108 | ||
109 | auto ret = facade.load(query); | 109 | auto ret = facade.load(query, Sink::Log::Context{"benchmark"}); |
110 | ret.first.exec().waitForFinished(); | 110 | ret.first.exec().waitForFinished(); |
111 | auto emitter = ret.second; | 111 | auto emitter = ret.second; |
112 | QList<Sink::ApplicationDomain::Event::Ptr> list; | 112 | QList<Sink::ApplicationDomain::Event::Ptr> 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 | |||
84 | { | 84 | { |
85 | const auto startingRss = getCurrentRSS(); | 85 | const auto startingRss = getCurrentRSS(); |
86 | 86 | ||
87 | |||
88 | // Benchmark | 87 | // Benchmark |
89 | QTime time; | 88 | QTime time; |
90 | time.start(); | 89 | time.start(); |
@@ -93,7 +92,7 @@ class MailQueryBenchmark : public QObject | |||
93 | context.mResourceAccess = QSharedPointer<TestResourceAccess>::create(); | 92 | context.mResourceAccess = QSharedPointer<TestResourceAccess>::create(); |
94 | TestMailResourceFacade facade(context); | 93 | TestMailResourceFacade facade(context); |
95 | 94 | ||
96 | auto ret = facade.load(query); | 95 | auto ret = facade.load(query, Sink::Log::Context{"benchmark"}); |
97 | ret.first.exec().waitForFinished(); | 96 | ret.first.exec().waitForFinished(); |
98 | auto emitter = ret.second; | 97 | auto emitter = ret.second; |
99 | QList<Mail::Ptr> list; | 98 | QList<Mail::Ptr> list; |