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.6.1 to 8.7.0

7

docs/api.md

@@ -1006,3 +1006,3 @@ # API

The listener is passed four arguments:
The listener is passed five arguments:

@@ -1013,2 +1013,3 @@ * `levelLabel` – the new level string, e.g `trace`

* `previousLevelValue` – the prior level number, e.g `30`
* `logger` – the logger instance from which the event originated

@@ -1028,4 +1029,4 @@ ```js

const logger = require('pino')()
logger.on('level-change', function (lvl, val, prevLvl, prevVal) {
if (logger !== this) {
logger.on('level-change', function (lvl, val, prevLvl, prevVal, instance) {
if (logger !== instance) {
return

@@ -1032,0 +1033,0 @@ }

@@ -65,38 +65,10 @@ # Pretty Printing

1. Install a prettifier module as a separate dependency, e.g. `npm install pino-pretty`.
1. Instantiate the logger with pretty printing enabled:
1. Instantiate the logger with the prettifier option:
```js
const pino = require('pino')
const log = pino({
prettyPrint: {
levelFirst: true
},
prettifier: require('pino-pretty')
})
```
Note: the default prettifier module is `pino-pretty`, so the preceding
example could be:
```js
const pino = require('pino')
const log = pino({
prettyPrint: {
levelFirst: true
}
})
```
See the [`pino-pretty` documentation][pp] for more information on the options
that can be passed via `prettyPrint`.
The default prettifier write stream does not guarantee final log writes.
Correspondingly, a warning is written to logs on the first synchronous flushing.
This warning may be suppressed by passing `suppressFlushSyncWarning : true` to
`prettyPrint`:
```js
const pino = require('pino')
const log = pino({
prettyPrint: {
suppressFlushSyncWarning: true
}
})
```
[pp]: https://github.com/pinojs/pino-pretty

@@ -108,3 +108,4 @@ 'use strict'

labels[preLevelVal],
preLevelVal
preLevelVal,
this
)

@@ -111,0 +112,0 @@ }

'use strict'
module.exports = { version: '8.6.1' }
module.exports = { version: '8.7.0' }
{
"name": "pino",
"version": "8.6.1",
"version": "8.7.0",
"description": "super fast, all natural json logger",

@@ -5,0 +5,0 @@ "main": "pino.js",

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

import type { EventEmitter } from "events";
// @ts-ignore -- gracefully falls back to `any` if not installed
import type { PrettyOptions as PinoPrettyOptions } from "pino-pretty";
import * as pinoStdSerializers from "pino-std-serializers";

@@ -102,8 +100,8 @@ import type { SonicBoom, SonicBoomOpts } from "sonic-boom";

*/
on(event: "level-change", listener: pino.LevelChangeEventListener): this;
addListener(event: "level-change", listener: pino.LevelChangeEventListener): this;
once(event: "level-change", listener: pino.LevelChangeEventListener): this;
prependListener(event: "level-change", listener: pino.LevelChangeEventListener): this;
prependOnceListener(event: "level-change", listener: pino.LevelChangeEventListener): this;
removeListener(event: "level-change", listener: pino.LevelChangeEventListener): this;
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;

@@ -230,3 +228,3 @@ /**

type LevelChangeEventListener = (
type LevelChangeEventListener<Options = LoggerOptions> = (
lvl: LevelWithSilent | string,

@@ -236,2 +234,3 @@ val: number,

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

@@ -281,2 +280,13 @@

interface DestinationStreamHasMetadata {
[symbols.needsMetadataGsym]: true;
lastLevel: number;
lastTime: string;
lastMsg: string;
lastObj: object;
lastLogger: pino.Logger;
}
type DestinationStreamWithMetadata = DestinationStream & ({ [symbols.needsMetadataGsym]?: false } | DestinationStreamHasMetadata);
interface StreamEntry {

@@ -315,4 +325,2 @@ stream: DestinationStream

interface PrettyOptions extends PinoPrettyOptions {}
interface LoggerOptions {

@@ -404,7 +412,2 @@ transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions

/**
* Enables pino.pretty. This is intended for non-production configurations. This may be set to a configuration
* object as outlined in http://getpino.io/#/docs/API?id=pretty. Default: `false`.
*/
prettyPrint?: boolean | PrettyOptions;
/**
* Allows to optionally define which prettifier module to use.

@@ -805,2 +808,3 @@ */

export type Bindings = pino.Bindings;
export type DestinationStreamWithMetadata = pino.DestinationStreamWithMetadata;
export type Level = pino.Level;

@@ -827,3 +831,2 @@ export type LevelWithSilent = pino.LevelWithSilent;

export interface MultiStreamRes extends pino.MultiStreamRes {}
export interface PrettyOptions extends pino.PrettyOptions {}
export interface StreamEntry extends pino.StreamEntry {}

@@ -830,0 +833,0 @@ export interface TransportBaseOptions extends pino.TransportBaseOptions {}

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

const instance = pino()
function handle (lvl, val, prevLvl, prevVal) {
function handle (lvl, val, prevLvl, prevVal, logger) {
equal(lvl, 'trace')

@@ -105,2 +105,3 @@ equal(val, 10)

equal(prevVal, 30)
equal(logger, instance)
}

@@ -130,2 +131,8 @@ instance.on('level-change', handle)

equal(count, 6)
instance.once('level-change', (lvl, val, prevLvl, prevVal, logger) => equal(logger, instance))
instance.level = 'info'
const child = instance.child({})
instance.once('level-change', (lvl, val, prevLvl, prevVal, logger) => equal(logger, child))
child.level = 'trace'
})

@@ -132,0 +139,0 @@

import { expectAssignable, expectType } from "tsd";
import pino from "../../";
import type {LevelWithSilent, Logger, LogFn, P} from "../../pino";
import type {LevelWithSilent, Logger, LogFn, P, DestinationStreamWithMetadata } from "../../pino";

@@ -17,1 +17,13 @@ // NB: can also use `import * as pino`, but that form is callable as `pino()`

expectAssignable<P.LevelWithSilent>(level);
function createStream(): DestinationStreamWithMetadata {
return { write() {} };
}
const stream = createStream();
// Argh. TypeScript doesn't seem to narrow unless we assign the symbol like so, and tsd seems to
// break without annotating the type explicitly
const needsMetadata: typeof pino.symbols.needsMetadataGsym = pino.symbols.needsMetadataGsym;
if (stream[needsMetadata]) {
expectType<number>(stream.lastLevel);
}

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

};
log.on("level-change", (lvl, val, prevLvl, prevVal) => {
log.on("level-change", (lvl, val, prevLvl, prevVal, logger) => {
console.log(lvl, val, prevLvl, prevVal);

@@ -196,28 +196,2 @@ });

const pretty = pino({
prettyPrint: {
colorize: true,
crlf: false,
errorLikeObjectKeys: ["err", "error"],
errorProps: "",
messageFormat: false,
ignore: "",
levelFirst: false,
messageKey: "msg",
timestampKey: "timestamp",
translateTime: "UTC:h:MM:ss TT Z",
},
});
const withMessageFormatFunc = pino({
prettyPrint: {
ignore: "requestId",
messageFormat: (log, messageKey: string) => {
const message = log[messageKey] as string;
if (log.requestId) return `[${log.requestId}] ${message}`;
return message;
},
},
});
const withTimeFn = pino({

@@ -334,2 +308,6 @@ timestamp: pino.stdTimeFunctions.isoTime,

log3.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {
instance.myLevel('foo');
});
const clog3 = log3.child({}, { customLevels: { childLevel: 120 } })

@@ -352,1 +330,2 @@ // child inherit parant

withChildCallback.onChild = (child: Logger) => {}
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