0.2.2 • Published 9 years ago

std-verbose v0.2.2

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

std-verbose.js

Build Status

Verbose output with colored prefix for the commandline.

Output a string or an object. Objects are serialized to yaml.

std-verbose

Installation

npm install std-verbose --save

Usage

var verbose = require('std-verbose');

verbose.minLevel = verbose.DEBUG;

verbose('Starting to wax the moon', verbose.INFO);
verbose('Finding a brush for the spoon', verbose.INFO);
verbose('User John is available', verbose.INFO);

verbose('Received a request:', verbose.DEBUG);
verbose({target: 'http://example.com', data: {first: 1, second: 'two', third: 'III'}}, verbose.DEBUG, '  ');

verbose('Response data doesn\'t contain expected key \'xyz\'', verbose.WARN);

verbose('Unable to continue, skipping this one', verbose.ERROR);

API

verbose(message, level, prefix);
  • 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.

verbose.stream = process.stdout;
0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago