0.0.4 • Published 5 years ago
layer-logging v0.0.4
layer-logging
Getting Started in 1 Minute
1) Provides logging levels:
ERROR
WARN
INFO
DEBUG
TRACE
SILENT
2) You can't set the level toSILENT
(It's special). 3) To use the logger, you instantiate it preferably providing at least onekey
. 4) You can use the static propertiesfilterIn
andfilterOut
to override the current level. 5) If a key is specified infilterIn
the log will go out no matter the level. 6) Same withfilterOut
, but if a key is specified on bothin
andout
, it will be skipped. 7) The only way to echoSILENT
logs, is by including thekey
infilterIn
Examples
Create Logger and Use It
const logger = new Logger('app');
logger.trace("Hello", "World");
// Prints:
// [2025-01-01T18:04:38.233Z] [INFO] [APP] Hello World
Log at Different Levels
const logger = new Logger('app');
Logger.setLevel('INFO');
logger.error('Something happened'); // Will go out
logger.trace('Small bit'); // Won't go out
logger.silent('Specific debug'); // Will never go out if 'app' is not on Logger.filterIn