1.0.5 • Published 5 years ago

skr-logger v1.0.5

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

skr-logger v1.0.5

This library exported as Node.js modules.

Installation

Using npm:

$ npm i -g npm

$ npm i --save skr-logger

In Node.js:

Load the module.

var logger = require('skr-logger');

How to use in application

If you want to create info logs

 logger.info('message to be logged'); # to create INFO logs

 logger.debug('message to be logged'); # to create DEBUG logs

 logger.error('message to be logged'); # to create ERROR logs

 logger.warn('message to be logged'); # to create WARN logs

 logger.trace('message to be logged'); # to create TRACE logs

 logger.fatal('message to be logged'); # to create FATAL logs

By using the above code, the log file will be automatically generated in logs folder. Which will be automatically created if not available. Also this logs will be generated as per date and as per below filenames.

INFO log file as:

 Apr_23_2019_INFO.log
 Apr_24_2019_INFO.log

DEBUG log file as:

 Apr_23_2019_DEBUG.log
 Apr_24_2019_DEBUG.log

ERROR log file as:

 Apr_23_2019_ERROR.log
 Apr_24_2019_ERROR.log

WARN log file as:

 Apr_23_2019_WARN.log
 Apr_24_2019_WARN.log

TRACE log file as:

 Apr_23_2019_TRACE.log
 Apr_24_2019_TRACE.log

FATAL log file as:

 Apr_23_2019_FATAL.log
 Apr_24_2019_FATAL.log

Below given example shows how the logs will be captured in a log file:

 2019-04-23T15:30:34.281Z    INFO     Message   # INFO logs
 2019-04-23T15:30:34.281Z    DEBUG    Message   # DEBUG logs
 2019-04-23T15:30:34.281Z    ERROR    Message   # ERROR logs
 2019-04-23T15:30:34.281Z    WARN     Message   # WARN logs
 2019-04-23T15:30:34.281Z    TRACE    Message   # TRACE logs
 2019-04-23T15:30:34.281Z    FATAL    Message   # FATAL logs