@desouza-engineering/logger
v1.0.4
Published
Basic logger of node applications. Ideal for quick setup and maintenance.
Downloads
6
Maintainers
Readme
Logger
A simple and light weight logger
Getting started
Install
npm install @desouza-engineering/logger
Use
Logger class
const {Logger, LogLevel} = require('@desouza-engineering/logger');
const logger = new Logger('issuername', LogLevel.LOG);
logger.critical('testing ctitical logger');
logger.error('testing error logger');
logger.log('testing default logger');
logger.info('testing info logger');
logger.debug('testing debug logger');
logger.trace('testing trace logger');
logger.logC('testing ctitical logger');
logger.logE('testing error logger');
logger.log('testing default logger');
logger.logI('testing info logger');
logger.logD('testing debug logger');
logger.logT('testing trace logger');
//[CRITICAL Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing critical logger
//[ERROR Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing error logger
//[LOG Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing default logger
//[CRITICAL Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing critical logger
//[ERROR Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing error logger
//[LOG Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing default logger
Using the builder
The builder allows you to set the logging level of the application in one place and create new loggers whenever needed.
Ideal usage would be to have a config file that exports the builder then import that builder wherever you need it and get a new logger.
const {LogLevel, LoggerBuilder} = require('@desouza-engineering/logger');
const builder = new LoggerBuilder(LogLevel.LOG);
const logger = builder.getLogger('issuername');
logger.critical('testing ctitical logger');
logger.error('testing error logger');
logger.log('testing default logger');
logger.info('testing info logger');
logger.debug('testing debug logger');
logger.trace('testing trace logger');
//[CRITICAL Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing critical logger
//[ERROR Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing error logger
//[LOG Sun Sep 22 2019 22:13:24 GMT-0500 issuername] testing default logger