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.1.1 to 8.2.0

6

logger.js

@@ -139,3 +139,3 @@ 'use strict'

req.id = genReqId(req)
req.id = genReqId(req, res)

@@ -159,3 +159,3 @@ const log = quietReqLogger ? logger.child({ [requestIdKey]: req.id }) : logger

if (autoLoggingIgnore !== null && shouldLogSuccess === true) {
const isIgnored = autoLoggingIgnore !== null && autoLoggingIgnore(req)
const isIgnored = autoLoggingIgnore(req)
shouldLogSuccess = !isIgnored

@@ -214,3 +214,3 @@ }

let nextReqId = 0
return function genReqId (req) {
return function genReqId (req, res) {
return req.id || (nextReqId = (nextReqId + 1) & maxInt)

@@ -217,0 +217,0 @@ }

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

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

"ts-node": "^10.3.0",
"tsd": "^0.21.0",
"tsd": "^0.22.0",
"typescript": "^4.4.4"

@@ -29,0 +29,0 @@ },

@@ -125,2 +125,3 @@ # pino-http  [![Build Status](https://img.shields.io/github/workflow/status/pinojs/pino-http/CI)](https://github.com/pinojs/pino-http/actions)

const server = http.createServer(handle)
const { randomUUID } = require('node:crypto')
const pino = require('pino')

@@ -132,3 +133,10 @@ const logger = require('pino-http')({

// Define a custom request id function
genReqId: function (req) { return req.id },
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)
return id
},

@@ -135,0 +143,0 @@ // Define custom serializers

@@ -289,7 +289,8 @@ 'use strict'

test('uses a custom genReqId function', function (t) {
t.plan(4)
t.plan(5)
const dest = split(JSON.parse)
let idToTest
function genReqId (req) {
function genReqId (req, res) {
t.ok(res, 'res is defined')
t.ok(req.url, 'The first argument must be the request parameter')

@@ -540,3 +541,4 @@ idToTest = (Date.now() + Math.random()).toString(32)

let idToTest
function genReqId (req) {
function genReqId (req, res) {
t.ok(res, 'res is defined')
t.ok(req.url, 'The first argument must be the request parameter')

@@ -543,0 +545,0 @@ idToTest = (Date.now() + Math.random()).toString(32)

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