Skip to content

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

Open
gngrchrl wants to merge 3 commits intoklaudiosinani:masterfrom
gngrchrl:master
Open

Included features from issue #56 - Global callback when log type is called#62
gngrchrl wants to merge 3 commits intoklaudiosinani:masterfrom
gngrchrl:master

Conversation

@gngrchrl
Copy link
Copy Markdown

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.

@Vimiso
Copy link
Copy Markdown

Vimiso commented May 31, 2019

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants