Added logic to serialize Error objects correctly

This should fix #97.
This commit is contained in:
Emile Cantin
2013-09-26 14:55:20 -04:00
parent 093f693232
commit abdba8e56f
4 changed files with 26 additions and 1 deletions
+5
View File
@@ -94,6 +94,11 @@ function workerAppender(config) {
}
function write(loggingEvent) {
// JSON.stringify(new Error('test')) returns {}, which is not really useful for us.
// The following allows us to serialize errors correctly.
if (loggingEvent && loggingEvent.stack && JSON.stringify(loggingEvent) === '{}') { // Validate that we really are in this case
loggingEvent = {stack : loggingEvent.stack};
}
socket.write(JSON.stringify(loggingEvent), 'utf8');
socket.write(END_MSG, 'utf8');
}