Option to log raw IRC traffic

This commit is contained in:
Pavel Djundik 2016-12-10 10:53:06 +02:00
parent 3e6a3651e9
commit 4dd79af9bb
3 changed files with 36 additions and 6 deletions

View File

@ -361,11 +361,24 @@ module.exports = {
primaryKey: "uid" primaryKey: "uid"
}, },
// Enables extra debugging output. Turn this on if you experience // Extra debugging
// IRC connection issues and want to file a bug report.
// //
// @type boolean // @type object
// @default false // @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,
},
}; };

View File

@ -67,6 +67,12 @@ function setHome(homePath) {
var userConfig = require(this.CONFIG_PATH); var userConfig = require(this.CONFIG_PATH);
this.config = _.extend(this.config, userConfig); 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) { function getUserConfigPath(name) {

View File

@ -81,12 +81,23 @@ module.exports = function(irc, network) {
}); });
} }
if (Helper.config.debug) { if (Helper.config.debug.ircFramework) {
irc.on("debug", function(message) { irc.on("debug", function(message) {
log.debug("[" + client.name + " (#" + client.id + ") on " + network.name + " (#" + network.id + ")]", 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) { irc.on("socket error", function(err) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,