summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-11 16:19:21 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-11 16:19:21 +0100
commite8c20757640348e71c45991776ec2e5e7eb75b24 (patch)
treee62a28d6b411b6d338ccf826d0c61e005bffad72 /common/index.cpp
parenta21a93a815c3916c1862d2b09f1589a7505dde07 (diff)
downloadsink-e8c20757640348e71c45991776ec2e5e7eb75b24.tar.gz
sink-e8c20757640348e71c45991776ec2e5e7eb75b24.zip
Use logging in storage as well.
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp18
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
4Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode) 8Index::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
11Index::Index(const QByteArray &name, Sink::Storage::Transaction &transaction) 16Index::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}