std-verbose.js
Verbose output with colored prefix for the commandline.
Output a string or an object. Objects are serialized to yaml.
Installation
npm install std-verbose --save
Usage
var verbose = ; verboseminLevel = verboseDEBUG; ;;; ;; ; ;
API
;
message
string (required)level
enum (optional), defaults to DEBUG.prefix
string (optional), defaults to''
.
Levels
There are 4 levels (from lowest to hightest):
- DEBUG
- INFO
- WARN
- ERROR
All messages with a level below verbose.minLevel
will not be outputted. Defaults to INFO.
The minimum level may also be set through environment variable VERBOSITY
.
Level methods
Alternatively you can call a method to output a message for a specific verbosity level.
verbose.debug('Received a request:');verbose.debug({target: 'http://example.com', data: {first: 1, second: 'two', third: 'III'}}, ' '); verbose.info('Starting to wax the moon');verbose.warn('This might take longer than expected');verbose.error('Something has gone wrong aborting');
Stream selection
By default messages are written to stderr. To write to another writable stream set verbose.stream
.
verbosestream = processstdout;