Add an uncaughtException handler to request a ticket and details.
Looks like this: * * * * The Bunyan CLI crashed! Please report this issue: * * https://github.com/trentm/node-bunyan/issues/new * * and include the following Bunyan details the log file * (or section of log file) on which the Bunyan CLI crashed. * * * * node version: v0.8.9 * bunyan version: 0.14.2 * argv: [ 'node', '/Users/trentm/tm/node-bunyan-0.x/bin/bunyan' ] * stack: * TypeError: Object.keys called on non-object * at Function.keys (native) * at emitRecord (/Users/trentm/tm/node-bunyan-0.x/bin/bunyan:718:14) * at handleLogLine (/Users/trentm/tm/node-bunyan-0.x/bin/bunyan:507:12) * at Socket.<anonymous> (/Users/trentm/tm/node-bunyan-0.x/bin/bunyan:856:7) * at Socket.EventEmitter.emit (events.js:88:17) * at Pipe.onread (net.js:391:31) * * *
This commit is contained in:
parent
46c63251a6
commit
337d7d977c
1 changed files with 26 additions and 0 deletions
26
bin/bunyan
26
bin/bunyan
|
@ -959,6 +959,32 @@ function asyncForEach(arr, iterator, callback) {
|
|||
|
||||
//---- mainline
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
function indent(s) {
|
||||
var lines = s.split(/\r?\n/);
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
lines[i] = '* ' + lines[i];
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
console.error('* * *');
|
||||
console.error('* The Bunyan CLI crashed! Please report this issue:');
|
||||
console.error('*');
|
||||
console.error('* https://github.com/trentm/node-bunyan/issues/new');
|
||||
console.error('*');
|
||||
console.error('* and include the following Bunyan details the log file');
|
||||
console.error('* (or section of log file) on which the Bunyan CLI crashed.');
|
||||
console.error('* * *');
|
||||
console.error('* node version:', process.version);
|
||||
console.error('* bunyan version:', getVersion());
|
||||
console.error('* argv:', process.argv);
|
||||
console.error('* stack:');
|
||||
console.error(indent(err.stack));
|
||||
console.error('* * *');
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
function main(argv) {
|
||||
var opts;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue