diff options
Diffstat (limited to 'common/index.cpp')
-rw-r--r-- | common/index.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/common/index.cpp b/common/index.cpp index f09e265..725c28b 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -2,31 +2,31 @@ | |||
2 | 2 | ||
3 | #include "log.h" | 3 | #include "log.h" |
4 | 4 | ||
5 | SINK_DEBUG_AREA("index") | ||
6 | |||
7 | Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::DataStore::AccessMode mode) | 5 | Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::DataStore::AccessMode mode) |
8 | : mTransaction(Sink::Storage::DataStore(storageRoot, name, mode).createTransaction(mode)), | 6 | : mTransaction(Sink::Storage::DataStore(storageRoot, name, mode).createTransaction(mode)), |
9 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), | 7 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), |
10 | mName(name) | 8 | mName(name), |
9 | mLogCtx("index." + name.toLatin1()) | ||
11 | { | 10 | { |
12 | } | 11 | } |
13 | 12 | ||
14 | Index::Index(const QByteArray &name, Sink::Storage::DataStore::Transaction &transaction) | 13 | Index::Index(const QByteArray &name, Sink::Storage::DataStore::Transaction &transaction) |
15 | : mDb(transaction.openDatabase(name, std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), mName(name) | 14 | : mDb(transaction.openDatabase(name, std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), mName(name), |
15 | mLogCtx("index." + name) | ||
16 | { | 16 | { |
17 | } | 17 | } |
18 | 18 | ||
19 | void Index::add(const QByteArray &key, const QByteArray &value) | 19 | void Index::add(const QByteArray &key, const QByteArray &value) |
20 | { | 20 | { |
21 | mDb.write(key, value, [&] (const Sink::Storage::DataStore::Error &error) { | 21 | mDb.write(key, value, [&] (const Sink::Storage::DataStore::Error &error) { |
22 | SinkWarning() << "Error while writing value" << error; | 22 | SinkWarningCtx(mLogCtx) << "Error while writing value" << error; |
23 | }); | 23 | }); |
24 | } | 24 | } |
25 | 25 | ||
26 | void Index::remove(const QByteArray &key, const QByteArray &value) | 26 | void Index::remove(const QByteArray &key, const QByteArray &value) |
27 | { | 27 | { |
28 | mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) { | 28 | mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) { |
29 | SinkWarning() << "Error while removing value: " << key << value << error << error.store; | 29 | SinkWarningCtx(mLogCtx) << "Error while removing value: " << key << value << error; |
30 | }); | 30 | }); |
31 | } | 31 | } |
32 | 32 | ||
@@ -38,7 +38,7 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr | |||
38 | return true; | 38 | return true; |
39 | }, | 39 | }, |
40 | [&](const Sink::Storage::DataStore::Error &error) { | 40 | [&](const Sink::Storage::DataStore::Error &error) { |
41 | SinkWarning() << "Error while retrieving value" << error.message; | 41 | SinkWarningCtx(mLogCtx) << "Error while retrieving value:" << error << mName; |
42 | errorHandler(Error(error.store, error.code, error.message)); | 42 | errorHandler(Error(error.store, error.code, error.message)); |
43 | }, | 43 | }, |
44 | matchSubStringKeys); | 44 | matchSubStringKeys); |
@@ -48,6 +48,6 @@ QByteArray Index::lookup(const QByteArray &key) | |||
48 | { | 48 | { |
49 | QByteArray result; | 49 | QByteArray result; |
50 | //We have to create a deep copy, otherwise the returned data may become invalid when the transaction ends. | 50 | //We have to create a deep copy, otherwise the returned data may become invalid when the transaction ends. |
51 | lookup(key, [&](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [this](const Index::Error &error) { SinkWarning() << "Error while retrieving value" << error.message; }); | 51 | lookup(key, [&](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [this](const Index::Error &) { }); |
52 | return result; | 52 | return result; |
53 | } | 53 | } |