diff --git a/lib/LoggingEvent.js b/lib/LoggingEvent.js index 616bb02..257f193 100644 --- a/lib/LoggingEvent.js +++ b/lib/LoggingEvent.js @@ -21,33 +21,19 @@ class LoggingEvent { this.level = level; this.context = Object.assign({}, context); this.pid = process.pid; - // if (cluster && cluster.isWorker) { - // this.cluster = { - // workerId: cluster.worker.id, - // worker: process.pid - // }; - // } } serialise() { - try { - const logData = this.data.map((e) => { - // JSON.stringify(new Error('test')) returns {}, which is not really useful for us. - // The following allows us to serialize errors correctly. - if (e && e.stack && CircularJSON.stringify(e) === '{}') { - e = { message: e.message, stack: e.stack }; - } - return e; - }); - this.data = logData; - return CircularJSON.stringify(this); - } catch (e) { - return new LoggingEvent( - 'log4js', - levels.ERROR, - ['Unable to serialise log event due to :', e] - ).serialise(); - } + const logData = this.data.map((e) => { + // JSON.stringify(new Error('test')) returns {}, which is not really useful for us. + // The following allows us to serialize errors correctly. + if (e && e.stack && CircularJSON.stringify(e) === '{}') { + e = { message: e.message, stack: e.stack }; + } + return e; + }); + this.data = logData; + return CircularJSON.stringify(this); } static deserialise(serialised) {