Giter Site home page Giter Site logo

micro-pino's Introduction

micro-pino

About

Log requests in micro with pino.

Usage

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

const logger = pino({
  name: 'my-app',
  serializers: pino.stdSerializers
});

module.exports = microPino( logger)(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

micro-pino's People

Contributors

antonvasin avatar

Watchers

Vadim Smakhtin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.