@bipboys/logger
v0.0.15
Published
Console logger
Downloads
11
Readme
Abstraction over using console.log with priority levels
Installation
This module is distributed via github npm registry (GitHub Packages) which is bundled with node and
should be installed as one of your project's dependencies
. See more about work with Github Packages and installing a package:
npm install @bipboys/logger
Usage
It couldn't be easier! You create an instance of a class with a name and the required priority. Then you call the required method to output the logging message to the console. The message will be displayed in the format shown below.
// default level
const log = new ConsoleLogger('Example Log');
log.error('test error');
log.info('test info');
log.verbose('test verbose');
log.warn('test warn');
log.log('test log');
log.debug('test debug');
log.trace('test trace');
-------------------------------
Priority - DEFAULT
-------------------------------
[ERROR] 46:04.704 Example Log - test error
[INFO] 46:04.705 Example Log - test info
[WARN] 46:04.706 Example Log - test warn
[INFO] 46:04.706 Example Log - test log
[DEBUG] 46:04.706 Example Log - test debug
[TRACE] 46:04.707 Example Log - test trace
Displays messages with the specified priority and higher to the console
// error level
log = new ConsoleLogger('Example Log', 'ERROR');
log.error('test error');
log.info('test info');
log.verbose('test verbose');
log.warn('test warn');
log.log('test log');
log.debug('test debug');
log.trace('test trace');
-------------------------------
Priority - ERROR
-------------------------------
[ERROR] 46:04.707 Example Log - test error
[TRACE] 46:04.707 Example Log - test trace
Priority Levels
- VERBOSE
- DEBUG
- INFO
- WARN
- ERROR
- TRACE