diff options
-rw-r--r-- | common/clientapi.cpp | 3 | ||||
-rw-r--r-- | common/facade.cpp | 3 | ||||
-rw-r--r-- | common/genericresource.cpp | 11 | ||||
-rw-r--r-- | common/listener.cpp | 3 | ||||
-rw-r--r-- | common/modelresult.cpp | 3 | ||||
-rw-r--r-- | common/pipeline.cpp | 3 | ||||
-rw-r--r-- | common/queryrunner.cpp | 3 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 46 | ||||
-rw-r--r-- | common/resourceaccess.h | 1 | ||||
-rw-r--r-- | common/typeindex.cpp | 3 | ||||
-rw-r--r-- | docs/logging.md | 27 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 3 | ||||
-rw-r--r-- | synchronizer/main.cpp | 4 |
13 files changed, 82 insertions, 31 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index be9f3fd..a13456b 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -39,6 +39,9 @@ | |||
39 | #include "storage.h" | 39 | #include "storage.h" |
40 | #include "log.h" | 40 | #include "log.h" |
41 | 41 | ||
42 | #undef DEBUG_AREA | ||
43 | #define DEBUG_AREA "client.clientapi" | ||
44 | |||
42 | namespace Sink | 45 | namespace Sink |
43 | { | 46 | { |
44 | 47 | ||
diff --git a/common/facade.cpp b/common/facade.cpp index 8cb776c..95fecd9 100644 --- a/common/facade.cpp +++ b/common/facade.cpp | |||
@@ -29,6 +29,9 @@ | |||
29 | 29 | ||
30 | using namespace Sink; | 30 | using namespace Sink; |
31 | 31 | ||
32 | #undef DEBUG_AREA | ||
33 | #define DEBUG_AREA "client.facade" | ||
34 | |||
32 | class ResourceAccessFactory { | 35 | class ResourceAccessFactory { |
33 | public: | 36 | public: |
34 | static ResourceAccessFactory &instance() | 37 | static ResourceAccessFactory &instance() |
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 29cd8b1..b49ca94 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -22,6 +22,9 @@ static int sBatchSize = 100; | |||
22 | 22 | ||
23 | using namespace Sink; | 23 | using namespace Sink; |
24 | 24 | ||
25 | #undef DEBUG_AREA | ||
26 | #define DEBUG_AREA "resource.changereplay" | ||
27 | |||
25 | /** | 28 | /** |
26 | * Replays changes from the storage one by one. | 29 | * Replays changes from the storage one by one. |
27 | * | 30 | * |
@@ -110,6 +113,9 @@ private: | |||
110 | ReplayFunction mReplayFunction; | 113 | ReplayFunction mReplayFunction; |
111 | }; | 114 | }; |
112 | 115 | ||
116 | #undef DEBUG_AREA | ||
117 | #define DEBUG_AREA "resource.commandprocessor" | ||
118 | |||
113 | /** | 119 | /** |
114 | * Drives the pipeline using the output from all command queues | 120 | * Drives the pipeline using the output from all command queues |
115 | */ | 121 | */ |
@@ -286,6 +292,8 @@ private: | |||
286 | InspectionFunction mInspect; | 292 | InspectionFunction mInspect; |
287 | }; | 293 | }; |
288 | 294 | ||
295 | #undef DEBUG_AREA | ||
296 | #define DEBUG_AREA "resource" | ||
289 | 297 | ||
290 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) | 298 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) |
291 | : Sink::Resource(), | 299 | : Sink::Resource(), |
@@ -312,7 +320,7 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c | |||
312 | QVariant expectedValue; | 320 | QVariant expectedValue; |
313 | s >> expectedValue; | 321 | s >> expectedValue; |
314 | inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() { | 322 | inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() { |
315 | Log() << "Inspection was successful: " << inspectionType << inspectionId << entityId; | 323 | Log_area("resource.inspection") << "Inspection was successful: " << inspectionType << inspectionId << entityId; |
316 | Sink::Notification n; | 324 | Sink::Notification n; |
317 | n.type = Sink::Commands::NotificationType_Inspection; | 325 | n.type = Sink::Commands::NotificationType_Inspection; |
318 | n.id = inspectionId; | 326 | n.id = inspectionId; |
@@ -384,7 +392,6 @@ KAsync::Job<void> GenericResource::replay(Sink::Storage &synchronizationStore, c | |||
384 | 392 | ||
385 | void GenericResource::removeFromDisk(const QByteArray &instanceIdentifier) | 393 | void GenericResource::removeFromDisk(const QByteArray &instanceIdentifier) |
386 | { | 394 | { |
387 | Warning() << "Removing from generic resource"; | ||
388 | Sink::Storage(Sink::storageLocation(), instanceIdentifier, Sink::Storage::ReadWrite).removeFromDisk(); | 395 | Sink::Storage(Sink::storageLocation(), instanceIdentifier, Sink::Storage::ReadWrite).removeFromDisk(); |
389 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".userqueue", Sink::Storage::ReadWrite).removeFromDisk(); | 396 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".userqueue", Sink::Storage::ReadWrite).removeFromDisk(); |
390 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronizerqueue", Sink::Storage::ReadWrite).removeFromDisk(); | 397 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronizerqueue", Sink::Storage::ReadWrite).removeFromDisk(); |
diff --git a/common/listener.cpp b/common/listener.cpp index 6b62552..323252b 100644 --- a/common/listener.cpp +++ b/common/listener.cpp | |||
@@ -39,6 +39,9 @@ | |||
39 | #include <QTime> | 39 | #include <QTime> |
40 | #include <QDataStream> | 40 | #include <QDataStream> |
41 | 41 | ||
42 | #undef DEBUG_AREA | ||
43 | #define DEBUG_AREA "resource.communication" | ||
44 | |||
42 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) | 45 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) |
43 | : QObject(parent), | 46 | : QObject(parent), |
44 | m_server(new QLocalServer(this)), | 47 | m_server(new QLocalServer(this)), |
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 3a9fb95..f28c665 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -24,6 +24,9 @@ | |||
24 | #include "domain/folder.h" | 24 | #include "domain/folder.h" |
25 | #include "log.h" | 25 | #include "log.h" |
26 | 26 | ||
27 | #undef DEBUG_AREA | ||
28 | #define DEBUG_AREA "client.modelresult" | ||
29 | |||
27 | static uint qHash(const Sink::ApplicationDomain::ApplicationDomainType &type) | 30 | static uint qHash(const Sink::ApplicationDomain::ApplicationDomainType &type) |
28 | { | 31 | { |
29 | Q_ASSERT(!type.resourceInstanceIdentifier().isEmpty()); | 32 | Q_ASSERT(!type.resourceInstanceIdentifier().isEmpty()); |
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index db79dc8..627550e 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -36,6 +36,9 @@ | |||
36 | #include "definitions.h" | 36 | #include "definitions.h" |
37 | #include "bufferutils.h" | 37 | #include "bufferutils.h" |
38 | 38 | ||
39 | #undef DEBUG_AREA | ||
40 | #define DEBUG_AREA "resource.pipeline" | ||
41 | |||
39 | namespace Sink | 42 | namespace Sink |
40 | { | 43 | { |
41 | 44 | ||
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index b49a3e0..63b5bcf 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -26,6 +26,9 @@ | |||
26 | #include "domainadaptor.h" | 26 | #include "domainadaptor.h" |
27 | #include "asyncutils.h" | 27 | #include "asyncutils.h" |
28 | 28 | ||
29 | #undef DEBUG_AREA | ||
30 | #define DEBUG_AREA "client.queryrunner" | ||
31 | |||
29 | using namespace Sink; | 32 | using namespace Sink; |
30 | 33 | ||
31 | /* | 34 | /* |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 2e87bc7..345622c 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -43,9 +43,10 @@ | |||
43 | #include <QBuffer> | 43 | #include <QBuffer> |
44 | 44 | ||
45 | #undef Trace | 45 | #undef Trace |
46 | #define Trace() Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess") | 46 | #define TracePrivate() Trace_area("client.communication." + resourceInstanceIdentifier) |
47 | #define Trace() Trace_area("client.communication." + d->resourceInstanceIdentifier) | ||
47 | #undef Log | 48 | #undef Log |
48 | #define Log(IDENTIFIER) Sink::Log::debugStream(Sink::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") | 49 | #define Log() Log_area("client.communication." + d->resourceInstanceIdentifier) |
49 | 50 | ||
50 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) | 51 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) |
51 | { | 52 | { |
@@ -168,7 +169,7 @@ KAsync::Job<void> ResourceAccess::Private::tryToConnect() | |||
168 | return !socket; | 169 | return !socket; |
169 | }, | 170 | }, |
170 | [this, counter](KAsync::Future<void> &future) { | 171 | [this, counter](KAsync::Future<void> &future) { |
171 | Trace() << "Loop"; | 172 | TracePrivate() << "Loop"; |
172 | KAsync::wait(50) | 173 | KAsync::wait(50) |
173 | .then(connectToServer(resourceInstanceIdentifier)) | 174 | .then(connectToServer(resourceInstanceIdentifier)) |
174 | .then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { | 175 | .then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { |
@@ -176,10 +177,10 @@ KAsync::Job<void> ResourceAccess::Private::tryToConnect() | |||
176 | socket = s; | 177 | socket = s; |
177 | future.setFinished(); | 178 | future.setFinished(); |
178 | }, | 179 | }, |
179 | [&future, counter](int errorCode, const QString &errorString) { | 180 | [&future, counter, this](int errorCode, const QString &errorString) { |
180 | const int maxRetries = 10; | 181 | const int maxRetries = 10; |
181 | if (*counter > maxRetries) { | 182 | if (*counter > maxRetries) { |
182 | Trace() << "Giving up"; | 183 | TracePrivate() << "Giving up"; |
183 | future.setError(-1, "Failed to connect to socket"); | 184 | future.setError(-1, "Failed to connect to socket"); |
184 | } else { | 185 | } else { |
185 | future.setFinished(); | 186 | future.setFinished(); |
@@ -192,21 +193,21 @@ KAsync::Job<void> ResourceAccess::Private::tryToConnect() | |||
192 | KAsync::Job<void> ResourceAccess::Private::initializeSocket() | 193 | KAsync::Job<void> ResourceAccess::Private::initializeSocket() |
193 | { | 194 | { |
194 | return KAsync::start<void>([this](KAsync::Future<void> &future) { | 195 | return KAsync::start<void>([this](KAsync::Future<void> &future) { |
195 | Trace() << "Trying to connect"; | 196 | TracePrivate() << "Trying to connect"; |
196 | connectToServer(resourceInstanceIdentifier).then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { | 197 | connectToServer(resourceInstanceIdentifier).then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { |
197 | Trace() << "Connected to resource, without having to start it."; | 198 | TracePrivate() << "Connected to resource, without having to start it."; |
198 | Q_ASSERT(s); | 199 | Q_ASSERT(s); |
199 | socket = s; | 200 | socket = s; |
200 | future.setFinished(); | 201 | future.setFinished(); |
201 | }, | 202 | }, |
202 | [this, &future](int errorCode, const QString &errorString) { | 203 | [this, &future](int errorCode, const QString &errorString) { |
203 | Trace() << "Failed to connect, starting resource"; | 204 | TracePrivate() << "Failed to connect, starting resource"; |
204 | //We failed to connect, so let's start the resource | 205 | //We failed to connect, so let's start the resource |
205 | QStringList args; | 206 | QStringList args; |
206 | args << resourceInstanceIdentifier; | 207 | args << resourceInstanceIdentifier; |
207 | qint64 pid = 0; | 208 | qint64 pid = 0; |
208 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { | 209 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { |
209 | Trace() << "Started resource " << pid; | 210 | TracePrivate() << "Started resource " << pid; |
210 | tryToConnect() | 211 | tryToConnect() |
211 | .then<void>([&future]() { | 212 | .then<void>([&future]() { |
212 | future.setFinished(); | 213 | future.setFinished(); |
@@ -232,12 +233,12 @@ ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier) | |||
232 | : ResourceAccessInterface(), | 233 | : ResourceAccessInterface(), |
233 | d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) | 234 | d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) |
234 | { | 235 | { |
235 | log("Starting access"); | 236 | Log() << "Starting access"; |
236 | } | 237 | } |
237 | 238 | ||
238 | ResourceAccess::~ResourceAccess() | 239 | ResourceAccess::~ResourceAccess() |
239 | { | 240 | { |
240 | log("Closing access"); | 241 | Log() << "Closing access"; |
241 | if (!d->resultHandler.isEmpty()) { | 242 | if (!d->resultHandler.isEmpty()) { |
242 | Warning() << "Left jobs running while shutting down ResourceAccess: " << d->resultHandler.keys(); | 243 | Warning() << "Left jobs running while shutting down ResourceAccess: " << d->resultHandler.keys(); |
243 | } | 244 | } |
@@ -400,7 +401,7 @@ void ResourceAccess::open() | |||
400 | 401 | ||
401 | void ResourceAccess::close() | 402 | void ResourceAccess::close() |
402 | { | 403 | { |
403 | log(QString("Closing %1").arg(d->socket->fullServerName())); | 404 | Log() << QString("Closing %1").arg(d->socket->fullServerName()); |
404 | Trace() << "Pending commands: " << d->pendingCommands.size(); | 405 | Trace() << "Pending commands: " << d->pendingCommands.size(); |
405 | Trace() << "Queued commands: " << d->commandQueue.size(); | 406 | Trace() << "Queued commands: " << d->commandQueue.size(); |
406 | d->socket->close(); | 407 | d->socket->close(); |
@@ -412,7 +413,7 @@ void ResourceAccess::sendCommand(const QSharedPointer<QueuedCommand> &command) | |||
412 | //TODO: we should have a timeout for commands | 413 | //TODO: we should have a timeout for commands |
413 | d->messageId++; | 414 | d->messageId++; |
414 | const auto messageId = d->messageId; | 415 | const auto messageId = d->messageId; |
415 | log(QString("Sending command \"%1\" with messageId %2").arg(QString(Sink::Commands::name(command->commandId))).arg(d->messageId)); | 416 | Log() << QString("Sending command \"%1\" with messageId %2").arg(QString(Sink::Commands::name(command->commandId))).arg(d->messageId); |
416 | Q_ASSERT(command->callback); | 417 | Q_ASSERT(command->callback); |
417 | registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) { | 418 | registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) { |
418 | Trace() << "Command complete " << messageId; | 419 | Trace() << "Command complete " << messageId; |
@@ -452,7 +453,7 @@ void ResourceAccess::connected() | |||
452 | return; | 453 | return; |
453 | } | 454 | } |
454 | 455 | ||
455 | log(QString("Connected: %1").arg(d->socket->fullServerName())); | 456 | Log() << QString("Connected: %1").arg(d->socket->fullServerName()); |
456 | 457 | ||
457 | { | 458 | { |
458 | flatbuffers::FlatBufferBuilder fbb; | 459 | flatbuffers::FlatBufferBuilder fbb; |
@@ -472,7 +473,7 @@ void ResourceAccess::connected() | |||
472 | 473 | ||
473 | void ResourceAccess::disconnected() | 474 | void ResourceAccess::disconnected() |
474 | { | 475 | { |
475 | log(QString("Disconnected from %1").arg(d->socket->fullServerName())); | 476 | Log() << QString("Disconnected from %1").arg(d->socket->fullServerName()); |
476 | d->socket->close(); | 477 | d->socket->close(); |
477 | emit ready(false); | 478 | emit ready(false); |
478 | } | 479 | } |
@@ -480,7 +481,7 @@ void ResourceAccess::disconnected() | |||
480 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) | 481 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) |
481 | { | 482 | { |
482 | if (error == QLocalSocket::PeerClosedError) { | 483 | if (error == QLocalSocket::PeerClosedError) { |
483 | Log(d->resourceInstanceIdentifier) << "The resource closed the connection."; | 484 | Log() << "The resource closed the connection."; |
484 | d->abortPendingOperations(); | 485 | d->abortPendingOperations(); |
485 | } else { | 486 | } else { |
486 | Warning() << QString("Connection error: %1 : %2").arg(error).arg(d->socket->errorString()); | 487 | Warning() << QString("Connection error: %1 : %2").arg(error).arg(d->socket->errorString()); |
@@ -524,14 +525,14 @@ bool ResourceAccess::processMessageBuffer() | |||
524 | switch (commandId) { | 525 | switch (commandId) { |
525 | case Commands::RevisionUpdateCommand: { | 526 | case Commands::RevisionUpdateCommand: { |
526 | auto buffer = Commands::GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize); | 527 | auto buffer = Commands::GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize); |
527 | log(QString("Revision updated to: %1").arg(buffer->revision())); | 528 | Log() << QString("Revision updated to: %1").arg(buffer->revision()); |
528 | emit revisionChanged(buffer->revision()); | 529 | emit revisionChanged(buffer->revision()); |
529 | 530 | ||
530 | break; | 531 | break; |
531 | } | 532 | } |
532 | case Commands::CommandCompletionCommand: { | 533 | case Commands::CommandCompletionCommand: { |
533 | auto buffer = Commands::GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize); | 534 | auto buffer = Commands::GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize); |
534 | log(QString("Command with messageId %1 completed %2").arg(buffer->id()).arg(buffer->success() ? "sucessfully" : "unsuccessfully")); | 535 | Log() << QString("Command with messageId %1 completed %2").arg(buffer->id()).arg(buffer->success() ? "sucessfully" : "unsuccessfully"); |
535 | 536 | ||
536 | d->completeCommands << buffer->id(); | 537 | d->completeCommands << buffer->id(); |
537 | //The callbacks can result in this object getting destroyed directly, so we need to ensure we finish our work first | 538 | //The callbacks can result in this object getting destroyed directly, so we need to ensure we finish our work first |
@@ -544,11 +545,11 @@ bool ResourceAccess::processMessageBuffer() | |||
544 | auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize); | 545 | auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize); |
545 | switch (buffer->type()) { | 546 | switch (buffer->type()) { |
546 | case Sink::Commands::NotificationType::NotificationType_Shutdown: | 547 | case Sink::Commands::NotificationType::NotificationType_Shutdown: |
547 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; | 548 | Log() << "Received shutdown notification."; |
548 | close(); | 549 | close(); |
549 | break; | 550 | break; |
550 | case Sink::Commands::NotificationType::NotificationType_Inspection: { | 551 | case Sink::Commands::NotificationType::NotificationType_Inspection: { |
551 | Log(d->resourceInstanceIdentifier) << "Received inspection notification."; | 552 | Log() << "Received inspection notification."; |
552 | Notification n; | 553 | Notification n; |
553 | if (buffer->identifier()) { | 554 | if (buffer->identifier()) { |
554 | //Don't use fromRawData, the buffer is gone once we invoke emit notification | 555 | //Don't use fromRawData, the buffer is gone once we invoke emit notification |
@@ -583,11 +584,6 @@ bool ResourceAccess::processMessageBuffer() | |||
583 | return d->partialMessageBuffer.size() >= headerSize; | 584 | return d->partialMessageBuffer.size() >= headerSize; |
584 | } | 585 | } |
585 | 586 | ||
586 | void ResourceAccess::log(const QString &message) | ||
587 | { | ||
588 | Log(d->resourceInstanceIdentifier) << this << message; | ||
589 | } | ||
590 | |||
591 | } | 587 | } |
592 | 588 | ||
593 | #pragma clang diagnostic push | 589 | #pragma clang diagnostic push |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index d10363e..3acc886 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -101,7 +101,6 @@ private Q_SLOTS: | |||
101 | 101 | ||
102 | private: | 102 | private: |
103 | void connected(); | 103 | void connected(); |
104 | void log(const QString &message); | ||
105 | void registerCallback(uint messageId, const std::function<void(int error, const QString &)> &callback); | 104 | void registerCallback(uint messageId, const std::function<void(int error, const QString &)> &callback); |
106 | 105 | ||
107 | void sendCommand(const QSharedPointer<QueuedCommand> &command); | 106 | void sendCommand(const QSharedPointer<QueuedCommand> &command); |
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index e58832c..b1bcf6a 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -22,6 +22,9 @@ | |||
22 | #include "index.h" | 22 | #include "index.h" |
23 | #include <QDateTime> | 23 | #include <QDateTime> |
24 | 24 | ||
25 | #undef DEBUG_AREA | ||
26 | #define DEBUG_AREA "common.typeindex" | ||
27 | |||
25 | TypeIndex::TypeIndex(const QByteArray &type) | 28 | TypeIndex::TypeIndex(const QByteArray &type) |
26 | : mType(type) | 29 | : mType(type) |
27 | { | 30 | { |
diff --git a/docs/logging.md b/docs/logging.md index a495a7a..3d5ea61 100644 --- a/docs/logging.md +++ b/docs/logging.md | |||
@@ -10,13 +10,34 @@ For debugging purposes a logging framework is required. Simple qDebugs() proved | |||
10 | * logfiles | 10 | * logfiles |
11 | * a commandline monitor tool | 11 | * a commandline monitor tool |
12 | * some other developer tool | 12 | * some other developer tool |
13 | This way we get complete logs also if some resource was not started from the console (i.e. because it was already running). | ||
13 | 14 | ||
14 | ## Debug levels | 15 | ## Debug levels |
15 | * trace: trace individual codepaths. Likely outputs way to much information for all normal cases and likely is only ever temporarily enabled. Trace points are likely only inserted into code fragments that are known to be problematic. | 16 | * trace: trace individual codepaths. Likely outputs way to much information for all normal cases and likely is only ever temporarily enabled for certain areas. |
16 | * log: Comprehensive debug output. Enabled on demand | 17 | * log: Comprehensive debug output. Enabled on demand |
17 | * warning: Only warnings, should always be logged. | 18 | * warning: Only warnings, should always be logged. |
18 | * error: Critical messages that should never appear. Should always be logged. | 19 | * error: Critical messages that should never appear. Should always be logged. |
19 | 20 | ||
21 | ## Debug areas | ||
22 | Debug areas split the code into sections that can be enabled/disabled as one. | ||
23 | This is supposed to give finer grained control over what is logged or displayed. | ||
24 | |||
25 | Debug areas may align with classes, but don't have to, the should be made so that they are useful. | ||
26 | |||
27 | Areas could be: | ||
28 | |||
29 | * resource.sync.performance | ||
30 | * resource.sync | ||
31 | * resource.listener | ||
32 | * resource.pipeline | ||
33 | * resource.store | ||
34 | * resource.communication | ||
35 | * client.communication | ||
36 | * client.communication.org.sink.resource.maildir.identifier1 | ||
37 | * client.queryrunner | ||
38 | * client.queryrunner.performance | ||
39 | * common.typeindex | ||
40 | |||
20 | ## Collected information | 41 | ## Collected information |
21 | Additionally to the regular message we want: | 42 | Additionally to the regular message we want: |
22 | 43 | ||
@@ -24,5 +45,5 @@ Additionally to the regular message we want: | |||
24 | * threadid? | 45 | * threadid? |
25 | * timestamp | 46 | * timestamp |
26 | * sourcefile + position + function name | 47 | * sourcefile + position + function name |
27 | * application name / resource identfier | 48 | * application name / resource identifier |
28 | * component identifier (i.e. resource access) | 49 | * area (i.e. resource access) |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index cb51881..77ce11c 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -46,6 +46,9 @@ | |||
46 | #define ENTITY_TYPE_MAIL "mail" | 46 | #define ENTITY_TYPE_MAIL "mail" |
47 | #define ENTITY_TYPE_FOLDER "folder" | 47 | #define ENTITY_TYPE_FOLDER "folder" |
48 | 48 | ||
49 | #undef DEBUG_AREA | ||
50 | #define DEBUG_AREA "resource.maildir" | ||
51 | |||
49 | MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline) | 52 | MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline) |
50 | : Sink::GenericResource(instanceIdentifier, pipeline), | 53 | : Sink::GenericResource(instanceIdentifier, pipeline), |
51 | mMailAdaptorFactory(QSharedPointer<MaildirMailAdaptorFactory>::create()), | 54 | mMailAdaptorFactory(QSharedPointer<MaildirMailAdaptorFactory>::create()), |
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index e9c17e7..d7a18e2 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp | |||
@@ -26,6 +26,9 @@ | |||
26 | #include "listener.h" | 26 | #include "listener.h" |
27 | #include "log.h" | 27 | #include "log.h" |
28 | 28 | ||
29 | #undef DEBUG_AREA | ||
30 | #define DEBUG_AREA "resource" | ||
31 | |||
29 | void crashHandler(int sig) { | 32 | void crashHandler(int sig) { |
30 | std::fprintf(stderr, "Error: signal %d\n", sig); | 33 | std::fprintf(stderr, "Error: signal %d\n", sig); |
31 | 34 | ||
@@ -70,6 +73,7 @@ int main(int argc, char *argv[]) | |||
70 | } | 73 | } |
71 | 74 | ||
72 | const QByteArray instanceIdentifier = argv[1]; | 75 | const QByteArray instanceIdentifier = argv[1]; |
76 | app.setApplicationName(instanceIdentifier); | ||
73 | 77 | ||
74 | QLockFile lockfile(instanceIdentifier + ".lock"); | 78 | QLockFile lockfile(instanceIdentifier + ".lock"); |
75 | lockfile.setStaleLockTime(500); | 79 | lockfile.setStaleLockTime(500); |