micro-pino

1.0.0 • Public • Published

micro-pino

About

Log requests in micro with pino.

Usage

const microPino = require('micro-pino');
const pino = require('pino')();

module.exports = microPino(pino)(async (res, req) => 'Hello world!');
{
  "level": 30,
  "time": 1530286753564,
  "msg": "Request 884d1305-dafd-481e-a2b3-941c30138927 finished",
  "pid": 79758,
  "hostname": "localdomain",
  "res": {
    "statusCode": 200,
    "header":
      "HTTP/1.1 200 OK\r\nAccess-Control-Request-Method: GET\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 43\r\nDate: Fri, 29 Jun 2018 15:39:13 GMT\r\nConnection: keep-alive\r\n\r\n"
  },
  "id": "884d1305-dafd-481e-a2b3-941c30138927",
  "duration": 5,
  "v": 1
}

Log object

id and duration are added to the log object. UUID v4 or X-Request-ID header is used for id and duration is calculated with hrtime

Package Sidebar

Install

npm i micro-pino

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.44 kB

Total Files

5

Last publish

Collaborators

  • antonvasin