diff --git a/package.json b/package.json index 2b10ec0..77428b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@navy.gif/logger", - "version": "1.1.1", + "version": "1.1.2", "description": "Logging thing", "main": "index.js", "author": "Navy.gif", diff --git a/src/MasterLogger.js b/src/MasterLogger.js index 3103819..b5a3f7e 100644 --- a/src/MasterLogger.js +++ b/src/MasterLogger.js @@ -38,6 +38,12 @@ class MasterLogger { return acc; }, {}); + process.on('message', (msg) => { + if (!msg._logger) return; + const { message, type } = msg; + this[type](message); + }); + } write (type = 'info', text, shard = null) { diff --git a/test/test.js b/test/test.js index 8f41ef4..e72aa83 100644 --- a/test/test.js +++ b/test/test.js @@ -1,7 +1,13 @@ /* eslint-disable no-console */ const { MasterLogger } = require('../'); -const logger = new MasterLogger({ debug: true, customTypes: [ 'access' ], customStreams: [ 'access' ], customTypeMapping: { access: 'access', warn: 'error' }, customColors: { access: 'green' } }); +const logger = new MasterLogger({ + debug: true, + customTypes: [ 'access' ], + customStreams: [ 'access' ], + customTypeMapping: { access: 'access', warn: 'error' }, + customColors: { access: 'green' } +}); const { types, colours, streamTypes, streamTypeMapping } = logger; // , writeStreams console.log(types, colours, streamTypes, streamTypeMapping); // , writeStreams