Skip to content

Commit

Permalink
WIP for issue #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
fgm committed Dec 2, 2016
1 parent 0592289 commit 13fb3bf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ServerLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import Logger from "./Logger";
import * as util from "util";

const serverCatcher = function (err) {
//Error.captureStackTrace(err);
console.log('Caught uE, err:', err);
};

/**
* An extension of the base logger which accepts log input on a HTTP URL.
*
Expand Down Expand Up @@ -43,6 +48,31 @@ class ServerLogger extends Logger {
this.setupConnect(webapp, this.servePath);
}

/**
* Arm the report subscriber.
*/
arm() {
console.log('Armed serverCatcher');
process.on('uncaughtException', serverCatcher);
// this.tk.report.subscribe(this.reportSubscriber.bind(this));
}

/**
* Disarm the subscriber.
*
* In most cases, we do not want to disarm immediately: a stack trace being
* build may take several hundred milliseconds, and we would lose it.
*
* @param delay
*/
disarm(delay = 2000) {
console.log('Request to disarm serverCatcher');
setTimeout(() => {
console.log('Disarmed serverCatcher');
process.removeListener('uncaughtException', serverCatcher);
}, delay);
}

/**
* Handle a log message from the client.
*
Expand Down

0 comments on commit 13fb3bf

Please sign in to comment.