From da2b049e248c1ad7efeb53685158a205335e4e36 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 22:23:49 +0200 Subject: A new debug system. Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names. --- .../mailtransportresource/mailtransportresource.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'examples/mailtransportresource/mailtransportresource.cpp') diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 1e93bdf..a729d4d 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp @@ -44,6 +44,8 @@ #define ENTITY_TYPE_MAIL "mail" +SINK_DEBUG_AREA("mailtransportresource") + using namespace Sink; //TODO fold into synchronizer @@ -58,7 +60,7 @@ public: KAsync::Job replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList &changedProperties) Q_DECL_OVERRIDE { if (operation == Sink::Operation_Creation) { - Trace() << "Dispatching message."; + SinkTrace() << "Dispatching message."; // return send(mail, mSettings); } else if (operation == Sink::Operation_Removal) { } else if (operation == Sink::Operation_Modification) { @@ -86,9 +88,9 @@ public: msg->setHead(KMime::CRLFtoLF(data)); msg->parse(); if (settings.testMode) { - Log() << "I would totally send that mail, but I'm in test mode." << mail.identifier(); + SinkLog() << "I would totally send that mail, but I'm in test mode." << mail.identifier(); auto path = resourceStorageLocation(mResourceInstanceIdentifier) + "/test/"; - Trace() << path; + SinkTrace() << path; QDir dir; dir.mkpath(path); QFile f(path+ mail.identifier()); @@ -97,9 +99,9 @@ public: f.close(); } else { if (MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8())) { - Log() << "Sent message successfully"; + SinkLog() << "Sent message successfully"; } else { - Log() << "Failed to send message"; + SinkLog() << "Failed to send message"; return KAsync::error(1, "Failed to send the message."); } } @@ -108,13 +110,13 @@ public: KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE { - Log() << " Synchronizing"; + SinkLog() << " Synchronizing"; return KAsync::start([this](KAsync::Future future) { Sink::Query query; QList toSend; - Log() << " Looking for mail"; + SinkLog() << " Looking for mail"; store().reader().query(query, [&](const ApplicationDomain::Mail &mail) -> bool { - Trace() << "Found mail: " << mail.identifier(); + SinkTrace() << "Found mail: " << mail.identifier(); if (!mail.getSent()) { toSend << mail; } -- cgit v1.2.3