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"
},
// 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,
},
};

View file

@ -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) {

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) {
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,