diff options
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r-- | common/storage_lmdb.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index 1efffc4..f899767 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -32,9 +32,14 @@ | |||
32 | #include <QMutex> | 32 | #include <QMutex> |
33 | 33 | ||
34 | #include <lmdb.h> | 34 | #include <lmdb.h> |
35 | #include "log.h" | ||
35 | 36 | ||
36 | namespace Sink | 37 | #undef Trace |
37 | { | 38 | #define Trace() Trace_area("storage." + d->storageRoot.toLatin1() + '/' + d->name.toLatin1()) |
39 | #undef Warning | ||
40 | #define Warning() Warning_area("storage") | ||
41 | |||
42 | namespace Sink { | ||
38 | 43 | ||
39 | int getErrorCode(int e) | 44 | int getErrorCode(int e) |
40 | { | 45 | { |
@@ -328,7 +333,7 @@ qint64 Storage::NamedDatabase::getSize() | |||
328 | MDB_stat stat; | 333 | MDB_stat stat; |
329 | rc = mdb_stat(d->transaction, d->dbi, &stat); | 334 | rc = mdb_stat(d->transaction, d->dbi, &stat); |
330 | if (rc) { | 335 | if (rc) { |
331 | qWarning() << "Something went wrong " << rc; | 336 | Warning() << "Something went wrong " << rc; |
332 | } | 337 | } |
333 | // std::cout << "overflow_pages: " << stat.ms_overflow_pages << std::endl; | 338 | // std::cout << "overflow_pages: " << stat.ms_overflow_pages << std::endl; |
334 | // std::cout << "page size: " << stat.ms_psize << std::endl; | 339 | // std::cout << "page size: " << stat.ms_psize << std::endl; |
@@ -452,7 +457,7 @@ Storage::NamedDatabase Storage::Transaction::openDatabase(const QByteArray &db, | |||
452 | QList<QByteArray> Storage::Transaction::getDatabaseNames() const | 457 | QList<QByteArray> Storage::Transaction::getDatabaseNames() const |
453 | { | 458 | { |
454 | if (!d) { | 459 | if (!d) { |
455 | qWarning() << "Invalid transaction"; | 460 | Warning() << "Invalid transaction"; |
456 | return QList<QByteArray>(); | 461 | return QList<QByteArray>(); |
457 | } | 462 | } |
458 | 463 | ||
@@ -470,10 +475,10 @@ QList<QByteArray> Storage::Transaction::getDatabaseNames() const | |||
470 | list << QByteArray::fromRawData((char*)key.mv_data, key.mv_size); | 475 | list << QByteArray::fromRawData((char*)key.mv_data, key.mv_size); |
471 | } | 476 | } |
472 | } else { | 477 | } else { |
473 | qWarning() << "Failed to get a value" << rc; | 478 | Warning() << "Failed to get a value" << rc; |
474 | } | 479 | } |
475 | } else { | 480 | } else { |
476 | qWarning() << "Failed to open db" << rc << QByteArray(mdb_strerror(rc)); | 481 | Warning() << "Failed to open db" << rc << QByteArray(mdb_strerror(rc)); |
477 | } | 482 | } |
478 | return list; | 483 | return list; |
479 | } | 484 | } |
@@ -596,7 +601,7 @@ qint64 Storage::diskUsage() const | |||
596 | { | 601 | { |
597 | QFileInfo info(d->storageRoot + '/' + d->name + "/data.mdb"); | 602 | QFileInfo info(d->storageRoot + '/' + d->name + "/data.mdb"); |
598 | if (!info.exists()) { | 603 | if (!info.exists()) { |
599 | qWarning() << "Tried to get filesize for non-existant file: " << info.path(); | 604 | Warning() << "Tried to get filesize for non-existant file: " << info.path(); |
600 | } | 605 | } |
601 | return info.size(); | 606 | return info.size(); |
602 | } | 607 | } |
@@ -606,7 +611,7 @@ void Storage::removeFromDisk() const | |||
606 | const QString fullPath(d->storageRoot + '/' + d->name); | 611 | const QString fullPath(d->storageRoot + '/' + d->name); |
607 | QMutexLocker locker(&d->sMutex); | 612 | QMutexLocker locker(&d->sMutex); |
608 | QDir dir(fullPath); | 613 | QDir dir(fullPath); |
609 | std::cout << "Removing database from disk: " << fullPath.toStdString() << std::endl; | 614 | Trace() << "Removing database from disk: " << fullPath; |
610 | if (!dir.removeRecursively()) { | 615 | if (!dir.removeRecursively()) { |
611 | Error error(d->name.toLatin1(), ErrorCodes::GenericError, QString("Failed to remove directory %1 %2").arg(d->storageRoot).arg(d->name).toLatin1()); | 616 | Error error(d->name.toLatin1(), ErrorCodes::GenericError, QString("Failed to remove directory %1 %2").arg(d->storageRoot).arg(d->name).toLatin1()); |
612 | defaultErrorHandler()(error); | 617 | defaultErrorHandler()(error); |