From 4dd79af9bb25b9d9bb47dedccddee398667f8bbe Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 10 Dec 2016 10:53:06 +0200 Subject: [PATCH] Option to log raw IRC traffic --- defaults/config.js | 23 ++++++++++++++++++----- src/helper.js | 6 ++++++ src/plugins/irc-events/connection.js | 13 ++++++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/defaults/config.js b/defaults/config.js index b392b762..9969b86c 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -361,11 +361,24 @@ module.exports = { primaryKey: "uid" }, - // Enables extra debugging output. Turn this on if you experience - // IRC connection issues and want to file a bug report. + // Extra debugging // - // @type boolean - // @default false + // @type object + // @default {} // - debug: false, + debug: { + // Enables extra debugging output provided by irc-framework. + // + // @type boolean + // @default false + // + ircFramework: false, + + // Enables logging raw IRC messages into each server window. + // + // @type boolean + // @default false + // + raw: false, + }, }; diff --git a/src/helper.js b/src/helper.js index 68e88919..c6e971c1 100644 --- a/src/helper.js +++ b/src/helper.js @@ -67,6 +67,12 @@ function setHome(homePath) { var userConfig = require(this.CONFIG_PATH); this.config = _.extend(this.config, userConfig); } + + // TODO: Remove in future release + if (this.config.debug === true) { + log.warn("debug option is now an object, see defaults file for more information."); + this.config.debug = {ircFramework: true}; + } } function getUserConfigPath(name) { diff --git a/src/plugins/irc-events/connection.js b/src/plugins/irc-events/connection.js index b4b95251..9da7d6e0 100644 --- a/src/plugins/irc-events/connection.js +++ b/src/plugins/irc-events/connection.js @@ -81,12 +81,23 @@ module.exports = function(irc, network) { }); } - if (Helper.config.debug) { + if (Helper.config.debug.ircFramework) { irc.on("debug", function(message) { log.debug("[" + client.name + " (#" + client.id + ") on " + network.name + " (#" + network.id + ")]", message); }); } + if (Helper.config.debug.raw) { + irc.on("raw", function(message) { + network.channels[0].pushMessage(client, new Msg({ + from: message.from_server ? "«" : "»", + self: !message.from_server, + type: "raw", + text: message.line + }), true); + }); + } + irc.on("socket error", function(err) { network.channels[0].pushMessage(client, new Msg({ type: Msg.Type.ERROR,