Package Exports
- console-log-level
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (console-log-level) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
console-log-level
A dead simple logger. Will log to STDOUT or STDERR depending on the
chosen log level. It uses console.info
, console.warn
and
console.error
and hence supports the same API.
Log levels supported: debug, info, warn, error and fatal.
Installation
npm install console-log-level
Example usage
var log = require('console-log-level')({ level: 'info' });
log.debug('a'); // will not do anything
log.info('b'); // will output 'b\n' on STDOUT
log.warn('c'); // will output 'c\n' on STDERR
log.error('d'); // will output 'd\n' on STDERR
log.fatal('e'); // will output 'e\n' on STDERR
Options
Configure the logger by passing an options object:
var log = require('console-log-level')({
prefix: function () { return new Date().toISOString(); },
level: 'info'
});
level
A string
to specify the log level. Defaults to info
.
prefix
Specify this option if you want to set a prefix for all log messages.
This must be a string
or a function
that returns a string.
License
MIT