🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

restify-pino-logger

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify-pino-logger

pino logging restify middleware

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
4
Created
Source

restify-pino-logger  Build Status

pino logging restify middleware

To our knowledge, restify-pino-logger is the fastest restify logger in town.

Benchmarks

Benchmarks log each request/response pair while returning 'hello world', using autocannon with 100 connections and 10 pipelined requests (autocannon -c 100 -p 10 http://localhost:3000).

  • restify.auditLogger + bunyan: 5483.82 req/sec
  • restify-bunyan-logger: 6306.73 req/sec
  • restify-logger: 7485.28 req/sec
  • restify-pino-logger: 8207.46 req/sec
  • restify-pino-logger (extreme): 8789.28 req/sec
  • restify-pino-logger (without restify): 22240.73 req/seq
  • restify-pino-logger (without restify and extreme): 25536 req/sec

All benchmarks where taken on a Macbook Pro 2013 (2.6GHZ i7, 16GB of RAM).

Whilst we're comparing restify-pino-logger against restify-logger this isn't really a fair contest.

restify-logger sits on top of morgan.

Morgan doesn't support logging arbitrary data, nor does it output JSON. Further Morgan uses a form of eval to achieve high speed logging. Whilst probably safe, using eval at all tends to cause concern, particular when it comes to server-side JavaScript.

The fact that restify-pino-logger achieves higher throughput with JSON logging and arbitrary data, without using eval, serves to emphasise the high-speed capabilities of restify-pino-logger.

With restify-pino-logger you can have features, safety and speed.

Install

npm i restify-pino-logger --save

Example

'use strict'

var restify = require('restify')
var server = restify.createServer({name: 'app'})

server.use(require('restify-pino-logger')())

server.get('/', function (req, res) {
  req.log.info('something else')
  res.send('hello world')
})

server.listen(3000)
$ node example.js | pino
[2016-04-20T20:50:01.260Z] INFO (11809 on MacBook-Pro-4.local): something else
    req: {
      "id": 1,
      "method": "GET",
      "url": "/",
      "headers": {
        "host": "localhost:3000",
        "user-agent": "curl/7.43.0",
        "accept": "*/*"
      },
      "remoteAddress": "::1",
      "remotePort": 55295
    }
[2016-04-20T20:50:01.267Z] INFO (11809 on MacBook-Pro-4.local): request completed
    res: {
      "statusCode": 200,
      "header": "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 13\r\nDate: Wed, 20 Apr 2016 20:50:01 GMT\r\nConnection: keep-alive\r\n\r\n"
    }
    responseTime: 8
    req: {
      "id": 1,
      "method": "GET",
      "url": "/",
      "headers": {
        "host": "localhost:3000",
        "user-agent": "curl/7.43.0",
        "accept": "*/*"
      },
      "remoteAddress": "::1",
      "remotePort": 55295
    }

API

restify-pino-logger has the same options of pino, look at them there. restify-pino-logger attaches some listeners to the request, so that it will log when the request is completed.

License

MIT

Keywords

restify

FAQs

Package last updated on 07 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts