log-cb

A better looking method to format errors and data from a callback.


Keywords
cb, log
License
MIT
Install
npm install log-cb@0.1.0

Documentation

log-cb NPM version Build Status

A better looking method to format errors and data from a callback.

// Use inside Node callbacks.
fs.readFile('LICENSE', log('Success!', 'Error :<'));

// Or promises
foo(10).catch(log('', 'Error happened'));

// You can use log.err above instead:
bar(99).catch(log.err('Error happened'));

Installation

$ npm install --save log-cb

API

log(passMessage, [failMessage])

Log custom message for passing

  • passMessage: What to log if your callback has no errors.
  • failMessage: What to log if your callback has errors. Defaults to something custom.

log.err(failMessage, [passMessage])

The reverse of the original function, for better syntax:

log('', 'it broke!');
// vs
log.err('it broke!');

License

MIT © Jamen Marz