layer-logging
v0.0.4
Published
Provides logging
Downloads
14
Readme
layer-logging
Getting Started in 1 Minute
- Provides logging levels:
ERROR
WARN
INFO
DEBUG
TRACE
SILENT
- You can't set the level to
SILENT
(It's special). - To use the logger, you instantiate it preferably providing at least one
key
. - You can use the static properties
filterIn
andfilterOut
to override the current level. - If a key is specified in
filterIn
the log will go out no matter the level. - Same with
filterOut
, but if a key is specified on bothin
andout
, it will be skipped. - The only way to echo
SILENT
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