adsl
Another dead simple logger inspired by the awesome 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 sets supported
npm (default)
error: 0 warn: 1 info: 2 verbose: 3 debug: 4 silly: 5
console-log-level:
fatal: 0 error: 1 warn: 2 info: 3 debug: 4
rfc5424:
emerg: 0 alert: 1 crit: 2 error: 3 warning: 4 notice: 5 info: 6 debug: 7
Installation
npm install adsl
Example usage
// example.jsconst adsl = const colors = const fs = const os = { if colorssupportsColor && styleslvl msg = styleslvlmsg return adsl} { wstream} var logWriteStream = fs const log = logloglog loglevel = 'debug' logloglog logWriteStream
Options
Configure the logger by passing an options object:
var log = level: 'info' levels: 'npm' { return level } { if shouldLog console }
level
A string
to specify the log level.
Defaults to :
adsl.defaultLevel
= "info"
levels
An string
to specify the log levels set used.
Defaults to:
adsl.defaultLevels
= "npm"
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.
transport
Function called by the logger at each logging operation.
This must be a function
or an array
of functions.
Defaults to : adsl.defaultTransport
=
{ shouldLog && consoleADSLoutputMaplvl || lvl || consolelog}
License
MIT