@codemaniac-technologies/codemaniac-logger
v1.0.1
Published
> CODEMANIAC Logger Class for microservice and application logging.
Readme
CODEMANIAC Logger
CODEMANIAC Logger Class for microservice and application logging.
Installation
- Install as an NPM package using the main brach of the codemaniac-logger git repository:
npm install --save https://github.com/CodeManiac-Technologies-Pvt-Ltd/codemaniac-logger.git
Dependencies
Node.js and NPM:
As with all of our modules, node.js and npm must be installed prior to use. If you've yet to install node or would like a introduction, check out Introducation to Node.js on node's official site.
API
Class: CMTLogger
This class is used to create an instance of the codemaniac logger.
Constructor:
new CMTLogger();Create a new logger object.
- Returns: { CMTLogger}
STATIC logger.errorLogger {Object}
- Generic winston logger.
STATIC logger.apiLogger {Function}
- Request and Response logging Express middleware.
logger.config {Object}
- Config object registered with the logger instance.
logger.logger {Object}
- Initialized logger instance.
logger.debugWhiteList {Array}
- When in debug mode, whitelist of filenames to allow logging.
logger.debugBlackList {Array}
- When in debug mode, blacklist of filenames to prevent from logging.
logger.logMessage(level, payLoad, ctx={}, encrSchema=null, category=null, root=null)
Performs logging with encryption as defined in the config for the instance.
cronPattern{String|Date} - Valid cron pattern string (see http://crontab.org/) or Date object.args{...*} - Arguments to passed to the jobFunction when executing
logger.init(paths, dirFilter, config, dataProtectService)
Updates the cronPattern or executation date for given job instance.
cronPattern{String|Date} - Valid cron pattern string (see http://crontab.org/) or Date object.
Usage
To use the logger, follow the below steps:
- Include the following in your application entrypoint file (usually
index.js):'use strict'; const CodemaniacLogger = require('codemaniac-logger'); const logger = new CodemaniacLogger(); scheduler.init(logConfig);
Tests
To run the test suite, first install dependencies the run
npm testnpm install npm testAnalyze code coverage:
npm run test-coverageAn HTML copy of the coverage report will be written to the
./coveragedirectory.Check adherance to style guidlines and detect potential problems:
npm run lintCheck for known security exploits of dependent packages:
npm run security
