Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-http

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-http - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

5

logger.js

@@ -16,2 +16,5 @@ 'use strict'

var useLevel = opts.useLevel || 'info'
delete opts.useLevel
var theStream = opts.stream || stream

@@ -41,3 +44,3 @@ delete opts.stream

log.info({
log[useLevel]({
res: this,

@@ -44,0 +47,0 @@ responseTime: responseTime

2

package.json
{
"name": "pino-http",
"version": "2.1.0",
"version": "2.2.0",
"description": "High-speed HTTP logger for Node.js",

@@ -5,0 +5,0 @@ "main": "logger.js",

@@ -92,24 +92,13 @@ # pino-http  [![Build Status](https://travis-ci.org/pinojs/pino-http.svg)](https://travis-ci.org/pinojs/pino-http)[![Coverage Status](https://coveralls.io/repos/github/pinojs/pino-http/badge.svg?branch=master)](https://coveralls.io/github/pinojs/pino-http?branch=master)

### pinoHttp([options], [stream])
### pinoHttp([opts], [stream])
#### options
`opts`: it has all the options as [pino](http://npm.im/pino) and
`pino-http` has the same options as [pino](http://npm.im/pino).
`pino-http` attaches listeners to the request, in order to log when the request completes
* `logger`: `pino-http` can reuse a pino instance if passed with the `logger` property
* `genReqId`: you can pass a function which gets used to generate a request id. The first argument is the request itself. As fallback `pino-http` is just using an integer. This default might not be the desired behavior if you're running multiple instances of the app
* `useLevel`: the logger level `pino-http` is using to log out the response. default: `info`
* `stream`: same as the second parameter
##### logger
`stream`: the destination stream. Could be passed in as an option too.
`pino-http` can reuse a pino instance if passed with the `logger`
property
##### genReqId
You can pass a `genReqId` function which gets used to generate a request id. The first argument is the request itself.
As fallback `pino-http` is just using an integer. This default might not be the desired behavior if you're running multiple instances of the app.
##### stream
The destination stream.
Could be passed as the second parameter or as an option.
#### Examples

@@ -136,3 +125,6 @@

res: pino.stdSerializers.res
}
},
// Logger level is `info` by default
useLevel: 'info'
})

@@ -152,3 +144,3 @@

### pinoHttp.stdSerializers.req
##### pinoHttp.stdSerializers.req

@@ -155,0 +147,0 @@ Generates a JSONifiable object from the HTTP `request` object passed to

@@ -86,2 +86,18 @@ 'use strict'

test('uses the log level passed in as an option', function (t) {
var dest = split(JSON.parse)
var logger = pinoHttp({ useLevel: 'debug', level: 'debug' }, dest)
setup(t, logger, function (err, server) {
t.error(err)
doGet(server)
})
dest.on('data', function (line) {
t.equal(line.level, 20, 'level')
t.notOk(line.useLevel, 'useLevel not forwarded')
t.end()
})
})
test('allocate a unique id to every request', function (t) {

@@ -88,0 +104,0 @@ t.plan(5)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc