print-messages
Because making console.log
easier to read and write is a double edge sword of time saving.
npm install print-messages
pm = ;
Besides normal stuff like colored log
, warn
, success
, and error
methods, we have 2 more
node
promise
Node.js usually has callbacks like function(err, result){ ...
user
Promises are becoming popular
var promiser = ;willSucceed = promiserdefer pm;willSucceed; // or we could have done this//willSucceed.reject("reject is red");
Examples
Basic log, warn, success, error
pm;pm;pm;pm;
Node callbacks
// Node callbacks are usually (err, res)pm;pm;
Promises
promise = ; willSucceed = promisedefer;willFail = promisedefer; pm;willSucceed; pm;willFail;
Patch Notes
v0.3.0
Updated from coffee-script to js.
Added newLine [=true]
and blankLine [=true]
options to determine if arguments should be on new lines and if each log should be preceeded by a blank line. Both false looks like this:
pm.newLine = false;
pm.blankLine = false;
Added a way to change colors.
pm.colors.error = 'magenta';
pm.colors.success = 'blue';
pm.init()
v0.2.2
Ensured at least 1 printed message will appear, even if first arg is an object
v0.2.0
Added pm.node_cb
for user.save(pm.node_cb('My message might be green or red'))
v0.1.0
Added pm.crash
and pm.crash_cb
for promise.otherwise(pm.crash)
or promise.otherwise(pm.crash_cb('with message'))
Added pm.error_cb
, pm.success_cb
, pm.warn_cb
, pm.log_cb
for user.save().error(pm.error_cb('it failed)); // logs: 'it failed'.red, errors...