create-logger
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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 to value
  • String - sets logLevel to defaultLevel + value.length

defaultValue = 4 (warn)

Instance

See pino's docs

Related

Readme

Keywords

Package Sidebar

Install

npm i create-logger

Weekly Downloads

1

Version

0.2.0

License

GPL-3.0-or-later

Unpacked Size

39.6 kB

Total Files

5

Last publish

Collaborators

  • jcyamo