From: Janne Koschinski Date: Thu, 14 Feb 2019 13:31:13 +0000 (+0100) Subject: Improve debugging for new IRCv3 functionality X-Git-Tag: test-travis-01~60 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=fad08c0bc53514b43fdf44e5a792a019b1414367 Improve debugging for new IRCv3 functionality --- diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index 7a6779c4..09d8037f 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -390,6 +390,8 @@ void Quassel::setupCliParser() options += { {"debug-irc", tr("Enable logging of all raw IRC messages to debug log, including passwords! In most cases you should also set --loglevel Debug")}, {"debug-irc-id", tr("Limit raw IRC logging to this network ID. Implies --debug-irc"), tr("database network ID"), "-1"}, + {"debug-irc-parsed", tr("Enable logging of all parsed IRC messages to debug log, including passwords! In most cases you should also set --loglevel Debug")}, + {"debug-irc-parsed-id", tr("Limit parsed IRC logging to this network ID. Implies --debug-irc-parsed"), tr("database network ID"), "-1"}, }; } diff --git a/src/core/ircparser.cpp b/src/core/ircparser.cpp index a030a6aa..8a6a7eb4 100644 --- a/src/core/ircparser.cpp +++ b/src/core/ircparser.cpp @@ -42,6 +42,9 @@ IrcParser::IrcParser(CoreSession* session) // Check if raw IRC logging is enabled _debugLogRawIrc = (Quassel::isOptionSet("debug-irc") || Quassel::isOptionSet("debug-irc-id")); _debugLogRawNetId = Quassel::optionValue("debug-irc-id").toInt(); + // Check if parsed IRC logging is enabled + _debugLogParsedIrc = (Quassel::isOptionSet("debug-irc-parsed") || Quassel::isOptionSet("debug-irc-parsed-id")); + _debugLogParsedNetId = Quassel::optionValue("debug-irc-parsed-id").toInt(); connect(this, &IrcParser::newEvent, coreSession()->eventManager(), &EventManager::postEvent); } @@ -110,6 +113,12 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent* e) return net->serverDecode(data); }, rawMsg, tags, prefix, cmd, params); + // Log the message if enabled and network ID matches or allows all + if (_debugLogParsedIrc && (_debugLogParsedNetId == -1 || net->networkId().toInt() == _debugLogParsedNetId)) { + // Include network ID + qDebug() << "IRC net" << net->networkId() << "<<" << tags << prefix << cmd << params; + } + QList events; EventManager::EventType type = EventManager::Invalid; diff --git a/src/core/ircparser.h b/src/core/ircparser.h index a119ae30..19b7e829 100644 --- a/src/core/ircparser.h +++ b/src/core/ircparser.h @@ -54,4 +54,6 @@ private: bool _debugLogRawIrc; ///< If true, include raw IRC socket messages in the debug log qint32 _debugLogRawNetId; ///< Network ID for logging raw IRC socket messages, or -1 for all + bool _debugLogParsedIrc; ///< If true, include parsed IRC socket messages in the debug log + qint32 _debugLogParsedNetId; ///< Network ID for logging parsed IRC socket messages, or -1 for all };