Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove pretty print in types, docs #1569

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 1 addition & 29 deletions docs/pretty.md
Expand Up @@ -62,40 +62,12 @@ will be written to the destination stream.
> be easily investigated at a later date.

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
10 changes: 0 additions & 10 deletions pino.d.ts
Expand Up @@ -17,8 +17,6 @@
// TypeScript Version: 4.4

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";
import type { SonicBoom, SonicBoomOpts } from "sonic-boom";
import type { WorkerOptions } from "worker_threads";
Expand Down Expand Up @@ -318,8 +316,6 @@ declare namespace pino {
(msg: string, ...args: any[]): void;
}

interface PrettyOptions extends PinoPrettyOptions {}

interface LoggerOptions {
transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions
/**
Expand Down Expand Up @@ -405,11 +401,6 @@ declare namespace pino {
* The string key to place any logged object under.
*/
nestedKey?: string;
/**
* 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.
*/
Expand Down Expand Up @@ -828,7 +819,6 @@ export interface LogFn extends pino.LogFn {}
export interface LoggerOptions extends pino.LoggerOptions {}
export interface MultiStreamOptions extends pino.MultiStreamOptions {}
export interface MultiStreamRes extends pino.MultiStreamRes {}
export interface PrettyOptions extends pino.PrettyOptions {}
export interface StreamEntry extends pino.StreamEntry {}
export interface TransportBaseOptions extends pino.TransportBaseOptions {}
export interface TransportMultiOptions extends pino.TransportMultiOptions {}
Expand Down
26 changes: 0 additions & 26 deletions test/types/pino.test-d.ts
Expand Up @@ -192,32 +192,6 @@ anotherRedacted.info({
anotherPath: "Not shown",
});

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({
timestamp: pino.stdTimeFunctions.isoTime,
});
Expand Down