Improve debugging for new IRCv3 functionality
authorJanne Koschinski <janne@kuschku.de>
Thu, 14 Feb 2019 13:31:13 +0000 (14:31 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 30 May 2019 20:59:25 +0000 (22:59 +0200)
src/common/quassel.cpp
src/core/ircparser.cpp
src/core/ircparser.h

index 7a6779c..09d8037 100644 (file)
@@ -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"},
         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"},
         };
     }
 
         };
     }
 
index a030a6a..8a6a7eb 100644 (file)
@@ -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 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);
 }
 
     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);
 
         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<Event*> events;
     EventManager::EventType type = EventManager::Invalid;
 
     QList<Event*> events;
     EventManager::EventType type = EventManager::Invalid;
 
index a119ae3..19b7e82 100644 (file)
@@ -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 _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
 };
 };