Skip to content

Commit

Permalink
fix: remove pretty print in types, docs (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
susmithagudapati committed Oct 6, 2022
1 parent 7c425f1 commit 5aec425
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 65 deletions.
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

0 comments on commit 5aec425

Please sign in to comment.