mobiotics-logger
v0.0.2
Published
manage console logs
Downloads
4
Maintainers
Readme
Install
npm i mobiotics-logger
Usage
import('mobiotics-logger'); //assigns global Logger Instance.
Logger.log('Log this message to console.');
Importing the library exposes Global Logger Instance to be used anywhere in your codebase.
Logger has different levels which can be accessed using Logger.levels
:
Logger.table(Logger.levels)
| ON | 0 | |-------|------| | WARN | 40 | | ERROR | 70 | | OFF | 100 |
Logger is initially set to ON which logs everything. You can however change levels using:
Logger.setLevel( Logger.levels.OFF);
Logger.log('nothing is logged');
Modules
Logger modules can be created which makes it easy to identify different logs.
const appLogger=Logger.get('App');
appLogger.log('call from app level');
//APP: call from app level
Logger modules can be set with their own custom level.
By default Logger modules gets assigned the level active in root Logger.
Logger.get()
internally creates instances which are identified by the name passed ensuring that duplicate instances are not created.