summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
commitda2b049e248c1ad7efeb53685158a205335e4e36 (patch)
tree1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /common/index.cpp
parent9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff)
downloadsink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz
sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip
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.
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/common/index.cpp b/common/index.cpp
index 151f7af..beed45c 100644
--- a/common/index.cpp
+++ b/common/index.cpp
@@ -2,8 +2,7 @@
2 2
3#include "log.h" 3#include "log.h"
4 4
5#undef Trace 5SINK_DEBUG_AREA("index")
6#define Trace() Trace_area("index." + mName.toLatin1())
7 6
8Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode) 7Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode)
9 : mTransaction(Sink::Storage(storageRoot, name, mode).createTransaction(mode)), 8 : mTransaction(Sink::Storage(storageRoot, name, mode).createTransaction(mode)),
@@ -34,8 +33,8 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr
34 resultHandler(value); 33 resultHandler(value);
35 return true; 34 return true;
36 }, 35 },
37 [errorHandler](const Sink::Storage::Error &error) { 36 [this, errorHandler](const Sink::Storage::Error &error) {
38 Warning() << "Error while retrieving value" << error.message; 37 SinkWarning() << "Error while retrieving value" << error.message;
39 errorHandler(Error(error.store, error.code, error.message)); 38 errorHandler(Error(error.store, error.code, error.message));
40 }, 39 },
41 matchSubStringKeys); 40 matchSubStringKeys);
@@ -45,6 +44,6 @@ QByteArray Index::lookup(const QByteArray &key)
45{ 44{
46 QByteArray result; 45 QByteArray result;
47 //We have to create a deep copy, otherwise the returned data may become invalid when the transaction ends. 46 //We have to create a deep copy, otherwise the returned data may become invalid when the transaction ends.
48 lookup(key, [&result](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [this](const Index::Error &error) { Trace() << "Error while retrieving value" << error.message; }); 47 lookup(key, [&result](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [this](const Index::Error &error) { SinkTrace() << "Error while retrieving value" << error.message; });
49 return result; 48 return result;
50} 49}