signale icon indicating copy to clipboard operation
signale copied to clipboard

Included features from issue #56 - Global callback when log type is called

Open tiehm opened this issue 5 years ago • 1 comments

This fixes issue #56 you can now set global callbacks for logs which will be called once the logger function is called. The callback function will get the exact same data which the user used.

const {Signale} = require('signale');

const options = {
  disabled: false,
  interactive: false,
  stream: process.stdout,
  scope: 'custom',
  types: {
    remind: {
      badge: '**',
      color: 'yellow',
      label: 'reminder',
      done: (...msg) => {
        // Do something with the logged message(s)
      }
    },
    santa: {
      badge: '🎅',
      color: 'red',
      label: 'santa'
    }
  }
};

const custom = new Signale(options);
custom.remind('Improve documentation.');
custom.santa('Hoho! You have an unused variable on L45.');

Calling custom.remind('Hello', ', I love cookies') will get passed to the done callback as ['Hello', ', I love cookies']. You can then use it for whatever logging purposes.

tiehm avatar Sep 15 '18 10:09 tiehm

Any update on this?

Vimiso avatar May 31 '19 14:05 Vimiso