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

pino

Package Overview
Dependencies
Maintainers
4
Versions
311
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino - npm Package Compare versions

Comparing version 7.6.3 to 7.6.4

20

lib/caller.js
'use strict'
const fs = require('fs')
function noOpPrepareStackTrace (_, stack) {

@@ -9,7 +7,3 @@ return stack

function isOutsideNodeModules (input) {
return typeof input === 'string' && fs.existsSync(input) && input.indexOf('node_modules') === -1
}
module.exports = function getCaller () {
module.exports = function getCallers () {
const originalPrepare = Error.prepareStackTrace

@@ -26,11 +20,13 @@ Error.prepareStackTrace = noOpPrepareStackTrace

const fileNames = []
for (const entry of entries) {
const file = entry ? entry.getFileName() : undefined
if (!entry) {
continue
}
if (isOutsideNodeModules(file)) {
return file
}
fileNames.push(entry.getFileName())
}
return entries[0] ? entries[0].getFileName() : undefined
return fileNames
}

39

lib/transport.js
'use strict'
const { createRequire } = require('module')
const getCaller = require('./caller')
const getCallers = require('./caller')
const { join, isAbsolute } = require('path')

@@ -82,5 +82,7 @@

function transport (fullOptions) {
const { pipeline, targets, options = {}, worker = {}, caller = getCaller() } = fullOptions
// This function call MUST stay in the top-level function of this module
const callerRequire = createRequire(caller)
const { pipeline, targets, options = {}, worker = {}, caller = getCallers() } = fullOptions
// Backwards compatibility
const callers = typeof caller === 'string' ? [caller] : caller
// This will be eventually modified by bundlers

@@ -122,12 +124,23 @@ const bundlerOverrides = '__bundlerPathsOverrides' in globalThis ? globalThis.__bundlerPathsOverrides : {}

switch (origin) {
// This hack should not be needed, however it would not work otherwise
// when testing it from this module and in examples.
case 'pino/file':
return join(__dirname, '..', 'file.js')
/* istanbul ignore next */
default:
// TODO we cannot test this on Windows.. might not work.
return callerRequire.resolve(origin)
if (origin === 'pino/file') {
return join(__dirname, '..', 'file.js')
}
let fixTarget
for (const filePath of callers) {
try {
fixTarget = createRequire(filePath).resolve(origin)
break
} catch (err) {
// Silent catch
continue
}
}
if (!fixTarget) {
throw new Error(`unable to determine transport target for "${origin}"`)
}
return fixTarget
}

@@ -134,0 +147,0 @@ }

{
"name": "pino",
"version": "7.6.3",
"version": "7.6.4",
"description": "super fast, all natural json logger",

@@ -88,3 +88,3 @@ "main": "pino.js",

"loglevel": "^1.6.7",
"pino-pretty": "^v7.3.0",
"pino-pretty": "^v7.4.0",
"pre-commit": "^1.2.2",

@@ -91,0 +91,0 @@ "proxyquire": "^2.1.3",

@@ -36,2 +36,4 @@ // Type definitions for pino 7.0

type CustomLevelLogger<Options> = Options extends LoggerOptions ? Record<keyof Options["customLevels"], LogFn> : never
interface redactOptions {

@@ -211,3 +213,3 @@ paths: string[];

type Logger = BaseLogger & LoggerExtras & Record<string, any>;
type Logger<Options = LoggerOptions> = BaseLogger & LoggerExtras & CustomLevelLogger<Options>;

@@ -744,3 +746,3 @@ type SerializedError = pinoStdSerializers.SerializedError;

*/
declare function pino(optionsOrStream?: LoggerOptions | DestinationStream): Logger;
declare function pino<Options extends LoggerOptions | DestinationStream>(optionsOrStream?: Options): Logger<Options>;

@@ -753,3 +755,3 @@ /**

*/
declare function pino(options: LoggerOptions, stream: DestinationStream): Logger;
declare function pino<Options extends LoggerOptions>(options: Options, stream: DestinationStream): Logger<Options>;

@@ -774,3 +776,3 @@

export type LogDescriptor = pino.LogDescriptor;
export type Logger = pino.Logger;
export type Logger<Options = LoggerOptions> = pino.Logger<Options>;
export type SerializedError = pino.SerializedError;

@@ -777,0 +779,0 @@ export type SerializerFn = pino.SerializerFn;

@@ -327,2 +327,14 @@ 'use strict'

test('pino.transport should error with unknown target', async ({ fail, equal }) => {
try {
pino.transport({
target: 'origin',
caller: 'unknown-file.js'
})
fail('must throw')
} catch (err) {
equal(err.message, 'unable to determine transport target for "origin"')
}
})
test('pino.transport with target pino-pretty', async ({ match, teardown }) => {

@@ -329,0 +341,0 @@ const destination = join(

import P, { pino } from "../../";
import { IncomingMessage, ServerResponse } from "http";
import { Socket } from "net";
import { expectError } from 'tsd'
import Logger = P.Logger;

@@ -93,2 +94,3 @@

pino({ base: null });
// @ts-expect-error
if ("pino" in log) console.log(`pino version: ${log.pino}`);

@@ -135,5 +137,2 @@

log.level = "myLevel";
log.myLevel("a message");
const listener = (lvl: any, val: any, prevLvl: any, prevVal: any) => {

@@ -309,1 +308,7 @@ console.log(lvl, val, prevLvl, prevVal);

}
// custom levels
const log3 = pino({ customLevels: { myLevel: 100 } })
expectError(log3.log())
log3.level = 'myLevel'
log3.myLevel('')
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