1.0.5 • Published 3 years ago
dsloglite v1.0.5
DSLoglite
DSLoglite is a very very light logging fashion to log colorized messages in the console.
Levels
ALL: 0,
TRACE: 20,
DEBUG: 30,
CONFIG: 40,
INFO: 50,
WARN: 60,
ERROR: 70,
FATAL: 80,
OFF: 90
Default level
By default, Level is ALL
. This parameter is global.
Change Level
setLevel(Level.TRACE)
Level changes impacts only current JS file but is not global. This allows you to configure the granularity of the logging for each Javascript file.
Use
test.js
const { trace, debug, config, info, warn, error, fatal, Level, getLevel, setLevel, Color } = require( 'dsloglite' )( __filename );
const message = 'This is a message written with different level of logging.';
trace(message);
debug(message);
config(message);
info(message);
warn(message);
error(message);
fatal(message);
__filename
if you wish to display source file in the log record.
Result if source file is test.js
Without filename
const { trace, debug, config, info, warn, error, fatal, Level, getLevel, setLevel, Color } = require( 'dsloglite' );
Notes
info(`${Color.DIM}${Color.FG_WHITE}#${numType2Published}${Color.RESET }\tPublished${Color.BRIGHT}${Color.FG_RED}${value}${Color.RESET} to ${Color.DIM}${Color.FG_WHITE}${broker.topics.publish.statesType_2}/${Color.RESET}${Color.BRIGHT}${Color.FG_WHITE}${message.uuid}${Color.RESET}`);