layer-logging
v0.0.4
Published
Provides logging
Readme
layer-logging
Getting Started in 1 Minute
- Provides logging levels:
ERRORWARNINFODEBUGTRACESILENT
- 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
filterInandfilterOutto override the current level. - If a key is specified in
filterInthe log will go out no matter the level. - Same with
filterOut, but if a key is specified on bothinandout, it will be skipped. - The only way to echo
SILENTlogs, is by including thekeyinfilterIn
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 WorldLog 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