diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-11 16:19:21 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-11 16:19:21 +0100 |
commit | e8c20757640348e71c45991776ec2e5e7eb75b24 (patch) | |
tree | e62a28d6b411b6d338ccf826d0c61e005bffad72 /common/index.cpp | |
parent | a21a93a815c3916c1862d2b09f1589a7505dde07 (diff) | |
download | sink-e8c20757640348e71c45991776ec2e5e7eb75b24.tar.gz sink-e8c20757640348e71c45991776ec2e5e7eb75b24.zip |
Use logging in storage as well.
Diffstat (limited to 'common/index.cpp')
-rw-r--r-- | common/index.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/common/index.cpp b/common/index.cpp index 25dfb7c..ae56da1 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -1,15 +1,21 @@ | |||
1 | #include "index.h" | 1 | #include "index.h" |
2 | #include <QDebug> | 2 | |
3 | #include "log.h" | ||
4 | |||
5 | #undef Trace | ||
6 | #define Trace() Trace_area("index." + mName.toLatin1()) | ||
3 | 7 | ||
4 | Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode) | 8 | Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode) |
5 | : mTransaction(Sink::Storage(storageRoot, name, mode).createTransaction(mode)), | 9 | : mTransaction(Sink::Storage(storageRoot, name, mode).createTransaction(mode)), |
6 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Sink::Storage::Error &)>(), true)) | 10 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Sink::Storage::Error &)>(), true)), |
11 | mName(name) | ||
7 | { | 12 | { |
8 | 13 | ||
9 | } | 14 | } |
10 | 15 | ||
11 | Index::Index(const QByteArray &name, Sink::Storage::Transaction &transaction) | 16 | Index::Index(const QByteArray &name, Sink::Storage::Transaction &transaction) |
12 | : mDb(transaction.openDatabase(name, std::function<void(const Sink::Storage::Error &)>(), true)) | 17 | : mDb(transaction.openDatabase(name, std::function<void(const Sink::Storage::Error &)>(), true)), |
18 | mName(name) | ||
13 | { | 19 | { |
14 | 20 | ||
15 | } | 21 | } |
@@ -32,7 +38,7 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr | |||
32 | return true; | 38 | return true; |
33 | }, | 39 | }, |
34 | [errorHandler](const Sink::Storage::Error &error) { | 40 | [errorHandler](const Sink::Storage::Error &error) { |
35 | qDebug() << "Error while retrieving value" << error.message; | 41 | Warning() << "Error while retrieving value" << error.message; |
36 | errorHandler(Error(error.store, error.code, error.message)); | 42 | errorHandler(Error(error.store, error.code, error.message)); |
37 | } | 43 | } |
38 | ); | 44 | ); |
@@ -45,8 +51,8 @@ QByteArray Index::lookup(const QByteArray &key) | |||
45 | [&result](const QByteArray &value) { | 51 | [&result](const QByteArray &value) { |
46 | result = value; | 52 | result = value; |
47 | }, | 53 | }, |
48 | [](const Index::Error &error) { | 54 | [this](const Index::Error &error) { |
49 | qDebug() << "Error while retrieving value" << error.message; | 55 | Trace() << "Error while retrieving value" << error.message; |
50 | }); | 56 | }); |
51 | return result; | 57 | return result; |
52 | } | 58 | } |