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

pino-http

Package Overview
Dependencies
Maintainers
4
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 8.3.3 to 8.4.0

2

index.d.ts

@@ -92,3 +92,5 @@ // Project: https://github.com/pinojs/pino-http#readme

[startTime]: number;
log: pino.Logger;
allLogs: pino.Logger[];
}
}

@@ -141,2 +141,4 @@

req: {
params: {},
query: {},
id: canBeUndefined('id'),

@@ -163,3 +165,6 @@ method: 'GET',

response[startTime] = Date.now();
// res.log and res.allLogs should be available
response.log.info("Logging works on response");
request.allLogs[0].info("allLogs available on response");
response.end("Hello world");
};

8

logger.js
'use strict'
const pino = require('pino')
const { pino, symbols: { stringifySym, chindingsSym } } = require('pino')
const serializers = require('pino-std-serializers')

@@ -106,3 +106,7 @@ const getCallerFile = require('get-caller-file')

if (customPropBindings) {
log = logger.child(customPropBindings)
const customPropBindingStr = logger[stringifySym](customPropBindings).replace(/[{}]/g, '')
const customPropBindingsStr = logger[chindingsSym]
if (!customPropBindingsStr.includes(customPropBindingStr)) {
log = logger.child(customPropBindings)
}
}

@@ -109,0 +113,0 @@

{
"name": "pino-http",
"version": "8.3.3",
"version": "8.4.0",
"description": "High-speed HTTP logger for Node.js",

@@ -14,3 +14,3 @@ "main": "logger.js",

"devDependencies": {
"@types/node": "^18.0.0",
"@types/node": "^20.1.0",
"autocannon": "^7.3.0",

@@ -20,3 +20,3 @@ "coveralls": "^3.0.0",

"pino-http-print": "^3.1.0",
"pino-pretty": "^9.0.0",
"pino-pretty": "^10.0.0",
"pre-commit": "^1.1.2",

@@ -27,4 +27,4 @@ "split2": "^4.0.0",

"ts-node": "^10.3.0",
"tsd": "^0.24.1",
"typescript": "^4.4.4"
"tsd": "^0.28.1",
"typescript": "^5.0.2"
},

@@ -31,0 +31,0 @@ "scripts": {

@@ -1,2 +0,2 @@

# pino-http  [![Build Status](https://img.shields.io/github/workflow/status/pinojs/pino-http/CI)](https://github.com/pinojs/pino-http/actions)
# pino-http  [![Build Status](https://img.shields.io/github/actions/workflow/status/pinojs/pino-http/ci.yml?branch=master)](https://github.com/pinojs/pino-http/actions)

@@ -118,2 +118,19 @@ High-speed HTTP logger for Node.js

##### Use as Express middleware
```js
const express = require('express')
const logger = require('pino-http')
const app = express()
app.use(logger())
function handle (req, res) {
req.log.info('something else')
res.end('hello world')
}
app.listen(3000)
```
##### Logger options

@@ -134,7 +151,6 @@

genReqId: function (req, res) {
if (req.id) return req.id
let id = req.get('X-Request-Id')
if (id) return id
id = randomUUID()
res.header('X-Request-Id', id)
const existingID = req.id ?? req.headers["x-request-id"]
if (existingID) return existingID
const id = randomUUID()
res.setHeader('X-Request-Id', id)
return id

@@ -207,2 +223,3 @@ },

req.log.info('something else')
res.log.info('just in case you need access to logging when only the response is in scope')
res.end('hello world')

@@ -290,2 +307,3 @@ }

logger(req, res)
res.log.info('log is available on both req and res');
res.end('hello world')

@@ -292,0 +310,0 @@ }).listen(3000)

@@ -1288,2 +1288,26 @@ 'use strict'

test('uses custom request properties and once customProps', function (t) {
const dest = split()
function customPropsHandler (req, res) {
return {
key1: 'value1'
}
}
const logger = pinoHttp({
customProps: customPropsHandler
}, dest)
setup(t, logger, function (err, server) {
t.error(err)
doGet(server)
})
dest.on('data', function (line) {
t.equal(line.match(/key1/g).length, 1, 'once customProps')
t.end()
})
})
test('dont pass custom request properties to log additional attributes', function (t) {

@@ -1290,0 +1314,0 @@ const dest = split(JSON.parse)

Sorry, the diff of this file is not supported yet

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