forked from GitHub/dbot
crash error reporting [#468]
This commit is contained in:
parent
c46f5c4f9b
commit
e80b695dfa
@ -2,7 +2,8 @@
|
|||||||
* Name: Log
|
* Name: Log
|
||||||
* Description: Log commands to a channel.
|
* Description: Log commands to a channel.
|
||||||
*/
|
*/
|
||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._,
|
||||||
|
process = require('process');
|
||||||
|
|
||||||
var log = function(dbot) {
|
var log = function(dbot) {
|
||||||
this.ignoredCommands = [];
|
this.ignoredCommands = [];
|
||||||
@ -18,6 +19,25 @@ var log = function(dbot) {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'logError': function(server, err) {
|
||||||
|
var stack = err.stack.split('\n').slice(1, dbot.config.debugLevel + 1),
|
||||||
|
logChannel = this.config.logChannel[server],
|
||||||
|
time = new Date().toUTCString();
|
||||||
|
|
||||||
|
dbot.say(server, logChannel, dbot.t('error_message', {
|
||||||
|
'time': time,
|
||||||
|
'error': 'Message: ' + err
|
||||||
|
}));
|
||||||
|
|
||||||
|
_.each(stack, function(stackLine, index) {
|
||||||
|
dbot.say(server, logChannel, dbot.t('error_message', {
|
||||||
|
'time': time,
|
||||||
|
'error': 'Stack[' + index + ']: ' +
|
||||||
|
stackLine.trim()
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
'ignoreCommand': function(commandName) {
|
'ignoreCommand': function(commandName) {
|
||||||
this.ignoredCommands.push(commandName);
|
this.ignoredCommands.push(commandName);
|
||||||
}
|
}
|
||||||
@ -36,6 +56,13 @@ var log = function(dbot) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
process.on('uncaughtException', function(err) {
|
||||||
|
_.each(this.config.logChannel, function(chan, server) {
|
||||||
|
this.api.logError(server, err);
|
||||||
|
}, this);
|
||||||
|
process.exit(1);
|
||||||
|
}.bind(this));
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,5 +3,7 @@
|
|||||||
"en": "[{time}] {user} ({channel}): {command}",
|
"en": "[{time}] {user} ({channel}): {command}",
|
||||||
"fr": "[{time}] {user} ({channel}): {command}",
|
"fr": "[{time}] {user} ({channel}): {command}",
|
||||||
"it": "[{time}] {user} ({channel}): {command}"
|
"it": "[{time}] {user} ({channel}): {command}"
|
||||||
|
},
|
||||||
|
"en": "[{time}] Error: {error}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user