pino-trace-logger
v1.0.4
Published
logger with id for each log
Downloads
5
Maintainers
Readme
pino-trace-logger
Get logs with traceId
for associate each.
Its useful for find unique user steps in logs
when you have many parallel requests in one time.
Installation
$ npm install pino-trace-logger
API
const logger = require('pino-trace-logger');
logger(function)
Create a new logger middleware function using
the given function
for getting trace value,
by default trace value will be getting from req.headers['x-request-id']
Example
const express = require('express');
const logger = require('pino-trace-logger');
const app = express();
app.use(logger());
app.get('/', function (req, res) {
logger.info('start processing');
res.end();
logger.info('finish processing');
});
app.listen(8080, () => {
logger.info('app is started');
});
Requirements
NodeJs version 12+