Socket
Socket
Sign inDemoInstall

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 6.3.3 to 6.4.0

import.test-d.ts

11

index.d.ts

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

declare function pinoHttp(opts?: Options, stream?: pino.DestinationStream): HttpLogger;
declare function PinoHttp(opts?: Options, stream?: pino.DestinationStream): HttpLogger;
declare function pinoHttp(stream?: pino.DestinationStream): HttpLogger;
declare function PinoHttp(stream?: pino.DestinationStream): HttpLogger;

@@ -29,6 +29,6 @@ export interface HttpLogger {

genReqId?: GenReqId | undefined;
useLevel?: pino.Level | undefined;
useLevel?: pino.LevelWithSilent | undefined;
stream?: pino.DestinationStream | undefined;
autoLogging?: boolean | AutoLoggingOptions | undefined;
customLogLevel?: ((res: ServerResponse, error: Error) => pino.Level) | undefined;
customLogLevel?: ((res: ServerResponse, error: Error) => pino.LevelWithSilent) | undefined;
customReceivedMessage?: ((req: IncomingMessage, res: ServerResponse) => string) | undefined;

@@ -67,3 +67,4 @@ customSuccessMessage?: ((res: ServerResponse) => string) | undefined;

export default pinoHttp;
export default PinoHttp;
export { PinoHttp as pinoHttp }

@@ -70,0 +71,0 @@ export const startTime: unique symbol;

/// <reference path="./index.d.ts"/>
/// <reference path="index.d.ts"/>

@@ -8,3 +8,3 @@ import { Writable } from 'stream';

import pino from 'pino';
import pinoHttp, { HttpLogger, ReqId, Options, GenReqId, AutoLoggingOptions, CustomAttributeKeys, StdSerializers, startTime } from './';
import pinoHttp, { HttpLogger, ReqId, Options, GenReqId, AutoLoggingOptions, CustomAttributeKeys, StdSerializers, startTime } from '.';
import { RequestListener } from 'http';

@@ -59,3 +59,3 @@

const rtnLevel = () => {
let rtn: pino.Level = 'debug';
let rtn: pino.LevelWithSilent = 'debug';
if (rand()) {

@@ -71,2 +71,4 @@ rtn = 'error';

rtn = 'warn';
} else if (rand()) {
rtn = 'silent';
}

@@ -73,0 +75,0 @@ return rtn;

@@ -93,2 +93,6 @@ 'use strict'

if (level === 'silent') {
return
}
if (err || this.err || this.statusCode >= 500) {

@@ -208,1 +212,3 @@ const error = err || this.err || new Error('failed with status code ' + this.statusCode)

module.exports.startTime = startTime
module.exports.default = pinoLogger
module.exports.pinoHttp = pinoLogger
{
"name": "pino-http",
"version": "6.3.3",
"version": "6.4.0",
"description": "High-speed HTTP logger for Node.js",

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

"get-caller-file": "^2.0.5",
"pino": "^7.0.5",
"pino": "^7.5.0",
"pino-std-serializers": "^5.0.0"

@@ -33,3 +33,3 @@ },

"fix": "standard --fix",
"test-types": "tsc && tsd && ts-node index.test-d.ts"
"test-types": "tsc && tsd && ts-node *.test-d.ts "
},

@@ -36,0 +36,0 @@ "author": "David Mark Clements",

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

* `useLevel`: the logger level `pino-http` is using to log out the response. default: `info`
* `customLogLevel`: set to a `function (res, err, req) => { /* returns level name string */ }`. This function will be invoked to determine the level at which the log should be issued. This option is mutually exclusive with the `useLevel` option. The first argument is the HTTP response. The second argument is an error object if an error has occurred in the request.
* `customLogLevel`: set to a `function (res, err, req) => { /* returns level name string */ }`. This function will be invoked to determine the level at which the log should be issued (`silent` will prevent logging). This option is mutually exclusive with the `useLevel` option. The first argument is the HTTP response. The second argument is an error object if an error has occurred in the request.
* `autoLogging`: set to `false`, to disable the automatic "request completed" and "request errored" logging. Defaults to `true`. If set to an object, you can provide more options.

@@ -152,2 +152,4 @@ * `autoLogging.ignore`: set to a `function (req) => { /* returns boolean */ }`. Useful for defining logic based on req properties (such as a user-agent header) to ignore successful requests.

return 'error'
} else if (res.statusCode >= 300 && res.statusCode < 400) {
return 'silent'
}

@@ -154,0 +156,0 @@ return 'info'

@@ -154,2 +154,28 @@ 'use strict'

test('no autoLogging if useLevel or customLogLevel is silent', function (t) {
const dest = split(JSON.parse)
const logger = pinoHttp(
{
customLogLevel: function (_res, _err, _req) {
return 'silent'
}
},
dest
)
setup(t, logger, function (err, server) {
t.error(err)
doGet(server)
})
setup(t, logger, function (err, server) {
t.error(err)
doGet(server, null, function () {
const line = dest.read()
t.equal(line, null)
t.end()
})
})
})
test('uses the custom invalid log level passed in as an option', function (t) {

@@ -156,0 +182,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