klaudiosinani / signale

Highly configurable logging utility
MIT License
8.93k stars 232 forks source link

Set global callback function for `success`, `error` , etc etc #56

Open joshuaquek opened 6 years ago

joshuaquek commented 6 years ago

Is your feature request related to a problem? Please describe. Would it be possible to allow one to set a global callback for each individual log type? Like whenever one calls .success() , it would run a particular callback globally, and if one calls .error() it would also run another global callback etc....same for all of the other logging commands.

Describe the solution you'd like Allow one to set a global callback for each log command. Success, Error, Fatal, Info... etc etc

joshuaquek commented 6 years ago

One possible implementation:

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

const options = {
  types: {
    error: {
      done: (message) => {
           // Do whatever you want with the logged msg. Log to DB etc.
       }
    },
    success: {
      done: (message) => {
           // Do whatever you want with the logged msg. Log to DB etc.
       }
    }
  }
};

const custom = new Signale(options);
custom.error('Custom Error Log');
custom.success('Custom Success Log');
ansarizafar commented 6 years ago

Any update on this issue?

zorbyte commented 5 years ago

Really could do with this being implemented...

Vimiso commented 5 years ago

+1!