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 /common/datastorequery.cpp | |
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 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index de2d124..2a2f3f5 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -303,7 +303,7 @@ public: | |||
303 | }; | 303 | }; |
304 | 304 | ||
305 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) | 305 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) |
306 | : mQuery(query), mType(type), mStore(store) | 306 | : mQuery(query), mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) |
307 | { | 307 | { |
308 | setupQuery(); | 308 | setupQuery(); |
309 | } | 309 | } |
@@ -417,7 +417,7 @@ void DataStoreQuery::setupQuery() | |||
417 | for (const auto &k : baseFilters.keys()) { | 417 | for (const auto &k : baseFilters.keys()) { |
418 | const auto comparator = baseFilters.value(k); | 418 | const auto comparator = baseFilters.value(k); |
419 | if (comparator.value.canConvert<Query>()) { | 419 | if (comparator.value.canConvert<Query>()) { |
420 | SinkTrace() << "Executing subquery for property: " << k; | 420 | SinkTraceCtx(mLogCtx) << "Executing subquery for property: " << k; |
421 | const auto result = executeSubquery(comparator.value.value<Query>()); | 421 | const auto result = executeSubquery(comparator.value.value<Query>()); |
422 | baseFilters.insert(k, Query::Comparator(QVariant::fromValue(result), Query::Comparator::In)); | 422 | baseFilters.insert(k, Query::Comparator(QVariant::fromValue(result), Query::Comparator::In)); |
423 | } | 423 | } |
@@ -485,20 +485,20 @@ QVector<QByteArray> DataStoreQuery::loadIncrementalResultSet(qint64 baseRevision | |||
485 | mStore.readRevisions(baseRevision, mType, [&](const QByteArray &key) { | 485 | mStore.readRevisions(baseRevision, mType, [&](const QByteArray &key) { |
486 | changedKeys << key; | 486 | changedKeys << key; |
487 | }); | 487 | }); |
488 | SinkTrace() << "Finished reading incremental result set:" << *revisionCounter; | 488 | SinkTraceCtx(mLogCtx) << "Finished reading incremental result set:" << *revisionCounter; |
489 | return changedKeys; | 489 | return changedKeys; |
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | ResultSet DataStoreQuery::update(qint64 baseRevision) | 493 | ResultSet DataStoreQuery::update(qint64 baseRevision) |
494 | { | 494 | { |
495 | SinkTrace() << "Executing query update"; | 495 | SinkTraceCtx(mLogCtx) << "Executing query update"; |
496 | auto incrementalResultSet = loadIncrementalResultSet(baseRevision); | 496 | auto incrementalResultSet = loadIncrementalResultSet(baseRevision); |
497 | SinkTrace() << "Changed: " << incrementalResultSet; | 497 | SinkTraceCtx(mLogCtx) << "Changed: " << incrementalResultSet; |
498 | mSource->add(incrementalResultSet); | 498 | mSource->add(incrementalResultSet); |
499 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { | 499 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { |
500 | if (mCollector->next([this, callback](const ResultSet::Result &result) { | 500 | if (mCollector->next([this, callback](const ResultSet::Result &result) { |
501 | SinkTrace() << "Got incremental result: " << result.entity.identifier() << result.operation; | 501 | SinkTraceCtx(mLogCtx) << "Got incremental result: " << result.entity.identifier() << result.operation; |
502 | callback(result); | 502 | callback(result); |
503 | })) | 503 | })) |
504 | { | 504 | { |
@@ -512,12 +512,12 @@ ResultSet DataStoreQuery::update(qint64 baseRevision) | |||
512 | 512 | ||
513 | ResultSet DataStoreQuery::execute() | 513 | ResultSet DataStoreQuery::execute() |
514 | { | 514 | { |
515 | SinkTrace() << "Executing query"; | 515 | SinkTraceCtx(mLogCtx) << "Executing query"; |
516 | 516 | ||
517 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { | 517 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { |
518 | if (mCollector->next([this, callback](const ResultSet::Result &result) { | 518 | if (mCollector->next([this, callback](const ResultSet::Result &result) { |
519 | if (result.operation != Sink::Operation_Removal) { | 519 | if (result.operation != Sink::Operation_Removal) { |
520 | SinkTrace() << "Got initial result: " << result.entity.identifier() << result.operation; | 520 | SinkTraceCtx(mLogCtx) << "Got initial result: " << result.entity.identifier() << result.operation; |
521 | callback(ResultSet::Result{result.entity, Sink::Operation_Creation, result.aggregateValues}); | 521 | callback(ResultSet::Result{result.entity, Sink::Operation_Creation, result.aggregateValues}); |
522 | } | 522 | } |
523 | })) | 523 | })) |