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. --- common/typeindex.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'common/typeindex.cpp') diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 9d71463..077bfa1 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp @@ -57,7 +57,7 @@ static QByteArray toSortableByteArray(const QDateTime &date) } -TypeIndex::TypeIndex(const QByteArray &type) : mType(type) +TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type) { } @@ -73,7 +73,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) { - // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); + // SinkTraceCtx(mLogCtx) << "Indexing " << mType + ".index." + property << value.toByteArray(); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -84,7 +84,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) { - // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); + // SinkTraceCtx(mLogCtx) << "Indexing " << mType + ".index." + property << value.toByteArray(); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -95,7 +95,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) { - //SinkTrace() << "Indexing " << mType + ".index." + property << getByteArray(value); + //SinkTraceCtx(mLogCtx) << "Indexing " << mType + ".index." + property << getByteArray(value); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -182,7 +182,7 @@ QVector TypeIndex::query(const Sink::QueryBase &query, QSet TypeIndex::query(const Sink::QueryBase &query, QSet TypeIndex::lookup(const QByteArray &property, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) { - SinkTrace() << "Index lookup on property: " << property << mSecondaryProperties.keys() << mProperties; + SinkTraceCtx(mLogCtx) << "Index lookup on property: " << property << mSecondaryProperties.keys() << mProperties; if (mProperties.contains(property)) { QVector keys; Index index(indexName(property), transaction); const auto lookupKey = getByteArray(value); index.lookup( lookupKey, [&, this](const QByteArray &value) { keys << value; }, [property, this](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << property; }); - SinkTrace() << "Index lookup on " << property << " found " << keys.size() << " keys."; + SinkTraceCtx(mLogCtx) << "Index lookup on " << property << " found " << keys.size() << " keys."; return keys; } else if (mSecondaryProperties.contains(property)) { //Lookups on secondary indexes first lookup the key, and then lookup the results again to resolve to entity id's @@ -220,7 +220,7 @@ QVector TypeIndex::lookup(const QByteArray &property, const QVariant const auto lookupKey = getByteArray(value); index.lookup( lookupKey, [&, this](const QByteArray &value) { secondaryKeys << value; }, [property, this](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << property; }); - SinkTrace() << "Looked up secondary keys: " << secondaryKeys; + SinkTraceCtx(mLogCtx) << "Looked up secondary keys: " << secondaryKeys; for (const auto &secondary : secondaryKeys) { keys += lookup(resultProperty, secondary, transaction); } -- cgit v1.2.3