From a35acab8ecdadb5547c445a41ca2a67d978ed4a6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 18 Apr 2015 12:16:34 +0200 Subject: Log messages --- common/commands.cpp | 33 +++++++++++++++++++++++++++++++++ common/commands.h | 4 ++++ common/resourceaccess.cpp | 4 ++-- 3 files changed, 39 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/commands.cpp b/common/commands.cpp index 1dfeabe..99313b9 100644 --- a/common/commands.cpp +++ b/common/commands.cpp @@ -28,6 +28,39 @@ namespace Akonadi2 namespace Commands { +QByteArray name(int commandId) +{ + switch(commandId) { + case UnknownCommand: + return "Unknown"; + case CommandCompletion: + return "Completion"; + case HandshakeCommand: + return "Handshake"; + case RevisionUpdateCommand: + return "RevisionUpdate"; + case SynchronizeCommand: + return "Synchronize"; + case FetchEntityCommand: + return "FetchEntity"; + case DeleteEntityCommand: + return "DeleteEntity"; + case ModifyEntityCommand: + return "ModifyEntity"; + case CreateEntityCommand: + return "CreateEntity"; + case SearchSourceCommand: + return "SearchSource"; + case ShutdownCommand: + return "Shutdown"; + case NotificationCommand: + return "Notification"; + case CustomCommand: + return "Custom"; + }; + return QByteArray("Invalid commandId"); +} + int headerSize() { return sizeof(int) + (sizeof(uint) * 2); diff --git a/common/commands.h b/common/commands.h index 0007ffc..1baedcc 100644 --- a/common/commands.h +++ b/common/commands.h @@ -22,6 +22,7 @@ #include #include +#include class QIODevice; @@ -47,6 +48,9 @@ enum CommandIds { CustomCommand = 0xffff }; + +QByteArray name(int commandId); + int AKONADI2COMMON_EXPORT headerSize(); void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId); void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 9ecdab1..1dba571 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -200,7 +200,7 @@ void ResourceAccess::sendCommand(const QSharedPointer &command) //TODO: we should have a timeout for commands d->messageId++; const auto messageId = d->messageId; - log(QString("Sending command %1 with messageId %2").arg(command->commandId).arg(d->messageId)); + log(QString("Sending command \"%1\" with messageId %2").arg(QString(Akonadi2::Commands::name(command->commandId))).arg(d->messageId)); if (command->callback) { registerCallback(d->messageId, [this, messageId, command](int number, QString foo) { d->pendingCommands.remove(messageId); @@ -215,7 +215,7 @@ void ResourceAccess::sendCommand(const QSharedPointer &command) void ResourceAccess::processCommandQueue() { //TODO: serialize instead of blast them all through the socket? - log(QString("We have %1 queued commands").arg(d->commandQueue.size())); + Trace() << "We have " << d->commandQueue.size() << " queued commands"; for (auto command: d->commandQueue) { sendCommand(command); } -- cgit v1.2.3