1.0.5 • Published 12 months ago
loglevel-colors v1.0.5
loglevel-colors
A pre-connfigured instance of loglevel with colors and prefixes
Usage
The default loglevel is DEBUG, but this can be configured either by setting the
env var LOGLEVEL, or passing the log level in as a second argument.
The possible log levels are:
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
Installation
npm install loglevel-colorsdefaults
const log = require('loglevel-colors')('Sample');
log.trace(`I'm a trace message!`);
log.debug(`I'm a debug message!`);
log.info(`I'm a info message!`);
log.warn(`I'm a warn message!`);
log.error(`I'm a error message!`);[Sample] DEBUG: I'm a debug message!
[Sample] INFO: I'm a info message!
[Sample] WARN: I'm a warn message!
[Sample] ERROR: I'm a error message!Setting WARN as the default level
const log = require('loglevel-colors')('Sample', 'WARN');
log.trace(`I'm a trace message!`);
log.debug(`I'm a debug message!`);
log.info(`I'm a info message!`);
log.warn(`I'm a warn message!`);
log.error(`I'm a error message!`);[Sample] WARN: I'm a warn message!
[Sample] ERROR: I'm a error message!