log-in-channel
No messy console.log's anymore! Log things in specific channels you can mute, unmute and give specific colors.
Install
$ npm install log-in-channel
or
$ yarn add log-in-channel
Usage
Define your own instance of Logger
in one file and use it in all other files!
// logger.helper.js; // an object containing the channel ids for easier use while developing ; // create logger/* { colorSupportType?: null | 'terminal' | 'chrome', // Define here in which environment you are // null --> no colored logs // 'terminal' --> colored logs where chalk (npm package) works // 'chrome' --> colored logs where css styled logs work channelIds: IChannelIds, channel: { '<id of channel>': { // channel config params options?: { style?: { color?: '<hexa color code>', // string backgroundColor?: '<hexa color code>', // string fontWeight?: '<400 | 700>', // string }, }, }, },} */ ; ;
// myfile.js; CustomLogger;
And if you don't want to have logs of one channel, you can mute it and unmute it, when you need it again.
CustomLogger; // mute single channel CustomLogger; // unmute single channel CustomLogger; // mute all channels CustomLogger; // unmute all channels
You can also add and remove event listeners to listen for log events.
const listenerId = CustomLogger; CustomLogger;
Last but not least you can remove all colors and log all messages as plain text if you want to.
CustomLogger; // reactivate CustomLogger;
Example
You can find an example in the example
directory.
Run with ts-node example/example.ts
or yarn run:example
or npm run run:example
!
License
This repo is licensed under the MIT License.