0.0.5 • Published 3 years ago

@biptik/logger v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ts rs license release

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 @biptik/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

  1. VERBOSE
  2. DEBUG
  3. INFO
  4. WARN
  5. ERROR
  6. TRACE

Usage with TypeScript

See the typescript usage example