Schlog
Simple Node.js logger
Installation
Install using yarn:
yarn add schlog
Or npm:
npm install schlog
Basic usage
const logger = Logger logger// or set LOG_LEVEL environment variable to any of the default levels// (by name or number)// defaults to info (2) logger// [21:52:58] WARN Test logger// nothing (since level is set to warn)
Default log levels: error
, warn
, info
, debug
or 0-4
error
and warn
will output to stderr while info
and debug
will output to stdout.
Log functions return the same thing they output to the console. Either the log line or nothing if the log level is set higher than the level called.
Example customization
const chalk = const schlog = const logger = schlogLoggerconst LogLevel = schlogLogLevelconst LogScope = schlogLogScope const logLevel = "fancy" chalkmagentaunderline 4 LogScopeSTDOUTlogger// will only output with levels priorities 4 or lower loggerlogger// [March 21st 2019, 11:53:11 pm] FANCY Test loggerlogger// FANCY Test loggerlogger// {"level":{"name":"fancy","priority":4,"scope":"stdout"},"message":"Test"}