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 8.16.2 to 8.17.0

docs/typescript.md

28

docs/transports.md

@@ -196,2 +196,21 @@ # Transports

### Writing to a custom transport & stdout
In case you want to both use a custom transport, and output the log entries with default processing to STDOUT, you can use 'pino/file' transport configured with `destination: 1`:
```js
const transports = [
{
target: 'pino/file',
options: { destination: 1 } // this writes to STDOUT
},
{
target: 'my-custom-transport',
options: { someParameter: true }
}
]
const logger = pino(pino.transport({ targets: transports })
```
### Creating a transport pipeline

@@ -242,5 +261,6 @@

}, {
// Use target: 'pino/file' to write to stdout
// without any change.
target: 'pino-pretty'
// Use target: 'pino/file' with STDOUT descriptor 1 to write
// logs without any change.
target: 'pino/file',
options: { destination: 1 }
}]

@@ -368,3 +388,3 @@ }

write (chunk, enc, cb) {
// apply a transform and send to stdout
// apply a transform and send to STDOUT
console.log(chunk.toString().toUpperCase())

@@ -371,0 +391,0 @@ cb()

@@ -10,2 +10,3 @@ * [Readme](/)

* [Asynchronous Logging](/docs/asynchronous.md)
* [Usage With TypeScript](/docs/typescript.md)
* [Ecosystem](/docs/ecosystem.md)

@@ -12,0 +13,0 @@ * [Benchmarks](/docs/benchmarks.md)

2

lib/meta.js
'use strict'
module.exports = { version: '8.16.2' }
module.exports = { version: '8.17.0' }
{
"name": "pino",
"version": "8.16.2",
"version": "8.17.0",
"description": "super fast, all natural json logger",

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

"ts-node": "^10.9.1",
"tsd": "^0.24.1",
"tsd": "^0.29.0",
"typescript": "^5.1.3",

@@ -102,0 +102,0 @@ "winston": "^3.7.2"

@@ -16,2 +16,3 @@ // Project: https://github.com/pinojs/pino.git, http://getpino.io

// James Bromwell <https://github.com/thw0rted>
// Zamiell <https://github.com/Zamiell>
// TypeScript Version: 4.4

@@ -35,3 +36,3 @@

type CustomLevelLogger<Options> = Options extends { customLevels: Record<string, number> } ? Record<keyof Options["customLevels"], LogFn> : Record<never, LogFn>
type CustomLevelLogger<CustomLevels extends string> = { [level in CustomLevels]: LogFn }

@@ -42,3 +43,3 @@ /**

*/
type OnChildCallback<Options = LoggerOptions> = <ChildOptions extends pino.ChildLoggerOptions>(child: pino.Logger<Options & ChildOptions>) => void
type OnChildCallback<CustomLevels extends string = never> = (child: pino.Logger<CustomLevels>) => void

@@ -51,3 +52,3 @@ export interface redactOptions {

export interface LoggerExtras<Options = LoggerOptions> extends EventEmitter {
export interface LoggerExtras<CustomLevels extends string = never> extends EventEmitter {
/**

@@ -67,3 +68,3 @@ * Exposes the Pino package version. Also available on the exported pino function.

*/
customLevels: { [key: string]: number };
customLevels: { [level in CustomLevels]: number };
/**

@@ -88,3 +89,3 @@ * Use only defined `customLevels` and omit Pino's levels.

*/
child<ChildOptions extends pino.ChildLoggerOptions = {}>(bindings: pino.Bindings, options?: ChildOptions): pino.Logger<Options & ChildOptions>;
child<ChildCustomLevels extends string = never>(bindings: pino.Bindings, options?: ChildLoggerOptions<ChildCustomLevels>): pino.Logger<CustomLevels | ChildCustomLevels>;

@@ -94,3 +95,3 @@ /**

*/
onChild: OnChildCallback<Options>;
onChild: OnChildCallback<CustomLevels>;

@@ -105,8 +106,8 @@ /**

*/
on<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
addListener<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
once<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
prependListener<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
prependOnceListener<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
removeListener<Opts = Options>(event: "level-change", listener: pino.LevelChangeEventListener<Opts>): this;
on(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;
addListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;
once(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;
prependListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;
prependOnceListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;
removeListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels>): this;

@@ -138,3 +139,23 @@ /**

/**
* The valid string interpolation placeholders are documented here:
* https://getpino.io/#/docs/api?id=logger
*/
interface StringInterpolationLetterToType {
s: string;
d: number;
o: object;
O: object;
j: object;
}
/** Helper type to extract the string interpolation placeholders and convert them to types. */
type ExtractArgs<T extends string> = T extends `${string}%${infer R}`
? R extends `${infer A}${infer B}`
? A extends keyof StringInterpolationLetterToType
? [StringInterpolationLetterToType[A], ...ExtractArgs<B>]
: ExtractArgs<B>
: ExtractArgs<R>
: []
declare namespace pino {

@@ -237,3 +258,3 @@ //// Exported types and interfaces

type LevelChangeEventListener<Options = LoggerOptions> = (
type LevelChangeEventListener<CustomLevels extends string = never> = (
lvl: LevelWithSilentOrString,

@@ -243,3 +264,3 @@ val: number,

prevVal: number,
logger: Logger<Options>
logger: Logger<CustomLevels>
) => void;

@@ -249,3 +270,3 @@

type Logger<Options = LoggerOptions> = BaseLogger & LoggerExtras<Options> & CustomLevelLogger<Options>;
type Logger<CustomLevels extends string = never> = BaseLogger & LoggerExtras<CustomLevels> & CustomLevelLogger<CustomLevels>;

@@ -328,10 +349,37 @@ type SerializedError = pinoStdSerializers.SerializedError;

interface LogFn {
// TODO: why is this different from `obj: object` or `obj: any`?
/* tslint:disable:no-unnecessary-generics */
<T extends object>(obj: T, msg?: string, ...args: any[]): void;
(obj: unknown, msg?: string, ...args: any[]): void;
(msg: string, ...args: any[]): void;
// The first overload has:
// - An object as the first argument. (But functions are explicitly disallowed, which count as objects.)
// - An optional string as the second argument.
// - N optional arguments after that corresponding to the string interpolation placeholders.
// e.g.
// logFn({ foo: "foo" });
// logFn({ foo: "foo" }, "bar");
// logFn({ foo: "foo" }, "Message with an interpolation value: %s", "bar");
// logFn({ foo: "foo" }, "Message with two interpolation values: %s %d", "bar", 123);
<T extends object, Msg extends string>(
// We want to disallow functions, which count as the "object" type.
obj: never extends T ? (T extends Function ? never : T) : T,
msg?: Msg,
...stringInterpolationArgs: ExtractArgs<Msg>
): void;
// The second overload has:
// - A string as the first argument.
// - N optional arguments after that corresponding to the string interpolation placeholders.
// e.g.
// logFn("foo");
// logFn("Message with an interpolation value: %s", "foo");
// logFn("Message with two interpolation values: %s %d", "foo", 123);
<Msg extends string>(msg: Msg, ...stringInterpolationArgs: ExtractArgs<Msg>): void;
// The third overload has:
// - A `number` or `boolean` as the first argument. (`symbol` is explicitly disallowed.)
// - No additional arguments should be allowed.
// e.g.
// logFn(123);
// logFn(true);
(arg: number | boolean): void;
}
interface LoggerOptions {
interface LoggerOptions<CustomLevels extends string = never> {
transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions

@@ -369,3 +417,3 @@ /**

*/
customLevels?: { [key: string]: number };
customLevels?: { [level in CustomLevels]: number };
/**

@@ -655,6 +703,6 @@ * Use this option to only use defined `customLevels` and omit Pino's levels.

interface ChildLoggerOptions {
interface ChildLoggerOptions<CustomLevels extends string = never> {
level?: LevelOrString;
serializers?: { [key: string]: SerializerFn };
customLevels?: { [key: string]: number };
customLevels?: { [level in CustomLevels]: number };
formatters?: {

@@ -809,3 +857,3 @@ level?: (label: string, number: number) => object;

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

@@ -818,3 +866,3 @@ /**

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

@@ -840,5 +888,5 @@

export type LevelWithSilentOrString = pino.LevelWithSilentOrString;
export type LevelChangeEventListener = pino.LevelChangeEventListener;
export type LevelChangeEventListener<CustomLevels extends string> = pino.LevelChangeEventListener<CustomLevels>;
export type LogDescriptor = pino.LogDescriptor;
export type Logger<Options = LoggerOptions> = pino.Logger<Options>;
export type Logger<CustomLevels extends string = never> = pino.Logger<CustomLevels>;
export type SerializedError = pino.SerializedError;

@@ -852,3 +900,3 @@ export type SerializerFn = pino.SerializerFn;

export interface BaseLogger extends pino.BaseLogger {}
export interface ChildLoggerOptions extends pino.ChildLoggerOptions {}
export interface ChildLoggerOptions<CustomLevels extends string = never> extends pino.ChildLoggerOptions<CustomLevels> {}
export interface DestinationStream extends pino.DestinationStream {}

@@ -858,3 +906,3 @@ export interface LevelMapping extends pino.LevelMapping {}

export interface LogFn extends pino.LogFn {}
export interface LoggerOptions extends pino.LoggerOptions {}
export interface LoggerOptions<CustomLevels extends string = never> extends pino.LoggerOptions<CustomLevels> {}
export interface MultiStreamOptions extends pino.MultiStreamOptions {}

@@ -861,0 +909,0 @@ export interface MultiStreamRes<TLevel = Level> extends pino.MultiStreamRes<TLevel> {}

![banner](pino-banner.png)
# pino
[![npm version](https://img.shields.io/npm/v/pino)](https://www.npmjs.com/package/pino)

@@ -12,14 +13,24 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/pinojs/pino/ci.yml)](https://github.com/pinojs/pino/actions)

* [Benchmarks ⇗](/docs/benchmarks.md)
* [API ⇗](/docs/api.md)
* [Browser API ⇗](/docs/browser.md)
* [Redaction ⇗](/docs/redaction.md)
* [Child Loggers ⇗](/docs/child-loggers.md)
* [Transports ⇗](/docs/transports.md)
* [Web Frameworks ⇗](/docs/web.md)
* [Pretty Printing ⇗](/docs/pretty.md)
* [Asynchronous Logging ⇗](/docs/asynchronous.md)
* [Ecosystem ⇗](/docs/ecosystem.md)
* [Help ⇗](/docs/help.md)
* [Long Term Support Policy ⇗](/docs/lts.md)
* [Readme](/)
* [API](/docs/api.md)
* [Browser API](/docs/browser.md)
* [Redaction](/docs/redaction.md)
* [Child Loggers](/docs/child-loggers.md)
* [Transports](/docs/transports.md)
* [Web Frameworks](/docs/web.md)
* [Pretty Printing](/docs/pretty.md)
* [Asynchronous Logging](/docs/asynchronous.md)
* [Usage With TypeScript](/docs/typescript.md)
* [Ecosystem](/docs/ecosystem.md)
* [Benchmarks](/docs/benchmarks.md)
* [Long Term Support](/docs/lts.md)
* [Help](/docs/help.md)
* [Log rotation](/docs/help.md#rotate)
* [Reopening log files](/docs/help.md#reopening)
* [Saving to multiple files](/docs/help.md#multiple)
* [Log filtering](/docs/help.md#filter-logs)
* [Transports and systemd](/docs/help.md#transport-systemd)
* [Duplicate keys](/docs/help.md#dupe-keys)
* [Log levels as labels instead of numbers](/docs/help.md#level-string)
* [Pino with `debug`](/docs/help.md#debug)

@@ -68,3 +79,2 @@ ## Install

<a name="essentials"></a>

@@ -71,0 +81,0 @@ ## Essentials

@@ -17,3 +17,5 @@ import P, { pino } from "../../";

info({ obj: { aa: "bbb" } }, "another");
setImmediate(info, "after setImmediate");
// The type definitions will not work properly when using higher order functions, so we have to
// perform a manual type assertion.
setImmediate(info as (msg: string) => void, "after setImmediate");
error(new Error("an error"));

@@ -112,3 +114,2 @@

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

@@ -260,3 +261,3 @@

throw new Error('Some error')
} catch (err) {
} catch (err: any) {
log.error(err)

@@ -270,5 +271,5 @@ }

info<StrictShape>({
info({
activity: "Required property",
});
} satisfies StrictShape);

@@ -329,2 +330,5 @@ const logLine: pino.LogDescriptor = {

const ccclog3 = clog3.child({})
expectError(ccclog3.nonLevel(''))
const withChildCallback = pino({

@@ -351,1 +355,18 @@ onChild: (child: Logger) => {}

fn(customLevelChildLogger); // missing foo typing
// unknown option
expectError(
pino({
hello: 'world'
})
);
// unknown option
expectError(
pino({
hello: 'world',
customLevels: {
'log': 30
}
})
);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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