create-logger
Creates a logger instance
It's basically wrapper around pino, but provides an additional API for setting the log level.
Install
$ npm install create-logger
Usage
import logger, {setLogLevel} from "create-logger"
setLogLevel(0) // silence the logger
setLogLevel(2) // only log errors
setLogLevel(5) // enable debug logs
logger.fatal("fatal") // will log if logLevel >= 1
logger.error("error") // will log if logLevel >= 2
logger.warn("warn") // will log if logLevel >= 3
logger.info("info") // will log if logLevel >= 4
logger.debug("debug") // will log if logLevel >= 5
logger.trace("trace") // will log if logLevel == 6
API
setLogLevel(value)
Sets the log level.
value
Type: Boolean|Integer|String
-
false
- sets logLevel to 0 (silent) -
true
- sets logLevel to 4 (info) -
0-6
- sets logLevel tovalue
-
String
- sets logLevel todefaultLevel + value.length
defaultValue = 4
(warn)
Instance
See pino's docs