From da2b049e248c1ad7efeb53685158a205335e4e36 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 22:23:49 +0200 Subject: A new debug system. Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names. --- common/typeindex.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'common/typeindex.cpp') diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 05bbf5c..78195d3 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp @@ -22,8 +22,7 @@ #include "index.h" #include -#undef DEBUG_AREA -#define DEBUG_AREA "common.typeindex" +SINK_DEBUG_AREA("typeindex") static QByteArray getByteArray(const QVariant &value) { @@ -63,7 +62,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { - // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); + // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -74,7 +73,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { - // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); + // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -85,7 +84,7 @@ template <> void TypeIndex::addProperty(const QByteArray &property) { auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { - // Trace() << "Indexing " << mType + ".index." + property << date.toString(); + // SinkTrace() << "Indexing " << mType + ".index." + property << date.toString(); Index(indexName(property), transaction).add(getByteArray(value), identifier); }; mIndexer.insert(property, indexer); @@ -143,12 +142,12 @@ ResultSet TypeIndex::query(const Sink::Query &query, QSet &appliedFi if (query.propertyFilter.contains(it.key()) && query.sortProperty == it.value()) { Index index(indexName(it.key(), it.value()), transaction); const auto lookupKey = getByteArray(query.propertyFilter.value(it.key()).value); - Trace() << "looking for " << lookupKey; + SinkTrace() << "looking for " << lookupKey; index.lookup(lookupKey, [&](const QByteArray &value) { keys << value; }, - [it](const Index::Error &error) { Warning() << "Error in index: " << error.message << it.key() << it.value(); }, true); + [it](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << it.key() << it.value(); }, true); appliedFilters << it.key(); appliedSorting = it.value(); - Trace() << "Index lookup on " << it.key() << it.value() << " found " << keys.size() << " keys."; + SinkTrace() << "Index lookup on " << it.key() << it.value() << " found " << keys.size() << " keys."; return ResultSet(keys); } } @@ -157,12 +156,12 @@ ResultSet TypeIndex::query(const Sink::Query &query, QSet &appliedFi Index index(indexName(property), transaction); const auto lookupKey = getByteArray(query.propertyFilter.value(property).value); index.lookup( - lookupKey, [&](const QByteArray &value) { keys << value; }, [property](const Index::Error &error) { Warning() << "Error in index: " << error.message << property; }); + lookupKey, [&](const QByteArray &value) { keys << value; }, [property](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << property; }); appliedFilters << property; - Trace() << "Index lookup on " << property << " found " << keys.size() << " keys."; + SinkTrace() << "Index lookup on " << property << " found " << keys.size() << " keys."; return ResultSet(keys); } } - Trace() << "No matching index"; + SinkTrace() << "No matching index"; return ResultSet(keys); } -- cgit v1.2.3