From 310b77a4a5f414fb2292b1132869fed140258956 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 8 Nov 2022 21:43:51 +0200 Subject: [PATCH] forgot a quite important part >.> --- package.json | 2 +- src/MasterLogger.js | 6 ++++++ test/test.js | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) 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