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: trace, debug, info, warn, error and fatal.
Installation
npm install console-log-level
Example usage
var log = level: 'info' log // will not do anythinglog // will not do anythinglog // will output 'c\n' on STDOUTlog // will output 'd\n' on STDERRlog // will output 'e\n' on STDERRlog // will output 'f\n' on STDERR
Options
Configure the logger by passing an options object:
var log = { return } 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.
Will get the level of the currently logged message as the first argument.
stderr
A boolean
to log everything to stderr. Defauls to false
.