dd-stan-logger
v1.0.8
Published
a simple repository to publish logs to provided nats connection
Downloads
6
Readme
dd-stan-logger
A simple repository to publish logs to provided NATS connection.
Usage
const stan = require('node-nats-streaming');
const connection = stan.connect('test-cluster', 'test');
connection.on('connect', () => {
console.log('>>> nats-streaming-server connected for publishing!');
let logger = require('dd-stan-logger')(connection,'subject_name');
logger.setLogLevel("debug");
logger.info('TID', 'ReqCorIdd', 'a test log msg', '{"input": "test"}', '{"output": "test"}', 600, (d) => console.log(d));
logger.log('warn', 'TID', 'ReqCorIdd', 'a test log msg', '{"input": "test"}', '{"output": "test"}', 600, (d) => console.log(d));
});
Note: Refer to driver folder for example
Methods
- error
- warn
- info
- http
- verbose
- debug
- silly
- log (takes log level as 1st parameter)
- getLogLevel (return current log level of the logger instance)
- setLogLevel (assigns log level for the logger instance)
To-Do
- create NATS connection if no connection is provided
- add event handler for reconnecting if connection is lost