Skip to content

Commit 6d0a310

Browse files
authoredSep 1, 2022
Remove all mentions of final (#1544)
Signed-off-by: Matteo Collina <hello@matteocollina.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 3388e68 commit 6d0a310

File tree

5 files changed

+0
-106
lines changed

5 files changed

+0
-106
lines changed
 

‎docs/api.md

-54
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* [Statics](#statics)
2525
* [pino.destination()](#pino-destination)
2626
* [pino.transport()](#pino-transport)
27-
* [pino.final()](#pino-final)
2827
* [pino.multistream()](#pino-multistream)
2928
* [pino.stdSerializers](#pino-stdserializers)
3029
* [pino.stdTimeFunctions](#pino-stdtimefunctions)
@@ -1150,59 +1149,6 @@ For more on transports, how they work, and how to create them see the [`Transpor
11501149
* `targets`: May be specified instead of `target`. Must be an array of transport configurations. Transport configurations include the aforementioned `options` and `target` options plus a `level` option which will send only logs above a specified level to a transport.
11511150
* `pipeline`: May be specified instead of `target`. Must be an array of transport configurations. Transport configurations include the aforementioned `options` and `target` options. All intermediate steps in the pipeline _must_ be `Transform` streams and not `Writable`.
11521151
1153-
<a id="pino-final"></a>
1154-
1155-
### `pino.final(logger, [handler]) => Function | FinalLogger`
1156-
1157-
__The use of `pino.final` is discouraged in Node.js v14+ and not required.
1158-
It will be removed in the next major version.__
1159-
1160-
The `pino.final` method can be used to acquire a final logger instance
1161-
or create an exit listener function. This is _not_ needed in Node.js v14+
1162-
as pino automatically can handle those.
1163-
1164-
The `finalLogger` is a specialist logger that synchronously flushes
1165-
on every write. This is important to guarantee final log writes,
1166-
when using `pino.destination({ sync: false })` target.
1167-
1168-
Since final log writes cannot be guaranteed with normal Node.js streams,
1169-
if the `destination` parameter of the `logger` supplied to `pino.final`
1170-
is a Node.js stream `pino.final` will throw.
1171-
1172-
The use of `pino.final` with `pino.destination` is not needed, as
1173-
`pino.destination` writes things synchronously.
1174-
1175-
#### `pino.final(logger, handler) => Function`
1176-
1177-
In this case the `pino.final` method supplies an exit listener function that can be
1178-
supplied to process exit events such as `exit`, `uncaughtException`,
1179-
`SIGHUP` and so on.
1180-
1181-
The exit listener function will call the supplied `handler` function
1182-
with an error object (or else `null`), a `finalLogger` instance followed
1183-
by any additional arguments the `handler` may be called with.
1184-
1185-
```js
1186-
process.on('uncaughtException', pino.final(logger, (err, finalLogger) => {
1187-
finalLogger.error(err, 'uncaughtException')
1188-
process.exit(1)
1189-
}))
1190-
```
1191-
1192-
#### `pino.final(logger) => FinalLogger`
1193-
1194-
In this case the `pino.final` method returns a finalLogger instance.
1195-
1196-
```js
1197-
var finalLogger = pino.final(logger)
1198-
finalLogger.info('exiting...')
1199-
```
1200-
1201-
* See [`destination` parameter](#destination)
1202-
* See [Exit logging help](/docs/help.md#exit-logging)
1203-
* See [Asynchronous logging ⇗](/docs/asynchronous.md)
1204-
* See [Log loss prevention ⇗](/docs/asynchronous.md#log-loss-prevention)
1205-
12061152
<a id="pino-multistream"></a>
12071153
12081154
### `pino.multistream(streamsArray, opts) => MultiStreamRes`

‎docs/help.md

-32
Original file line numberDiff line numberDiff line change
@@ -289,35 +289,3 @@ log.info({ msg: 'mapped to originalMsg' }, 'a message')
289289
// {"level":30,"time":1596313323106,"pid":63739,"hostname":"foo","msg":"no original message"}
290290
// {"level":30,"time":1596313323107,"pid":63739,"hostname":"foo","msg":"a message","originalMsg":"mapped to originalMsg"}
291291
```
292-
293-
<a id="exit-logging"></a>
294-
## Exit logging (deprecated for Node v14+)
295-
296-
__In pino v7, The following piece of documentation is not needed in Node v14+ and it will
297-
emit a deprecation notice.__
298-
299-
When a Node process crashes from uncaught exception, exits due to a signal,
300-
or exits of it's own accord we may want to write some final logs – particularly
301-
in cases of error.
302-
303-
Writing to a Node.js stream on exit is not necessarily guaranteed, and naively writing
304-
to an asynchronous logger on exit will definitely lead to lost logs.
305-
306-
To write logs in an exit handler, create the handler with [`pino.final`](/docs/api.md#pino-final):
307-
308-
```js
309-
process.on('uncaughtException', pino.final(logger, (err, finalLogger) => {
310-
finalLogger.error(err, 'uncaughtException')
311-
process.exit(1)
312-
}))
313-
314-
process.on('unhandledRejection', pino.final(logger, (err, finalLogger) => {
315-
finalLogger.error(err, 'unhandledRejection')
316-
process.exit(1)
317-
}))
318-
```
319-
320-
The `finalLogger` is a special logger instance that will synchronously and reliably
321-
flush every log line. This is important in exit handlers, since no more asynchronous
322-
activity may be scheduled.
323-

‎lib/tools.js

-3
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,6 @@ function createArgsNormalizer (defaultOptions) {
298298
throw new Error('prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)')
299299
}
300300

301-
if ('onTerminated' in opts) {
302-
throw Error('The onTerminated option has been removed, use pino.final instead')
303-
}
304301
const { enabled } = opts
305302
if (enabled === false) opts.level = 'silent'
306303
if (!stream) {

‎pino.d.ts

-15
Original file line numberDiff line numberDiff line change
@@ -746,20 +746,6 @@ declare namespace pino {
746746
streamsArray: (DestinationStream | StreamEntry)[] | DestinationStream | StreamEntry,
747747
opts?: MultiStreamOptions
748748
): MultiStreamRes
749-
750-
/**
751-
* The pino.final method can be used to create an exit listener function.
752-
* This listener function can be supplied to process exit events.
753-
* The exit listener function will call the handler with
754-
* @param [logger]: pino logger that serves as reference for the final logger
755-
* @param [handler]: Function that will be called by the handler returned from this function
756-
* @returns Exit listener function that can be supplied to process exit events and will call the supplied handler function
757-
*/
758-
export function final(
759-
logger: Logger,
760-
handler: (error: Error, finalLogger: Logger, ...args: any[]) => void,
761-
): (error: Error | null, ...args: any[]) => void;
762-
export function final(logger: Logger): Logger;
763749
}
764750

765751
//// Callable default export
@@ -785,7 +771,6 @@ declare function pino<Options extends LoggerOptions>(options: Options, stream: D
785771
export const destination: typeof pino.destination;
786772
export const transport: typeof pino.transport;
787773
export const multistream: typeof pino.multistream;
788-
export const final: typeof pino.final;
789774
export const levels: typeof pino.levels;
790775
export const stdSerializers: typeof pino.stdSerializers;
791776
export const stdTimeFunctions: typeof pino.stdTimeFunctions;

‎test/types/pino-top-export.test-d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { SonicBoom } from "sonic-boom";
33

44
import {
55
destination,
6-
final,
76
LevelMapping,
87
levels,
98
Logger,
@@ -20,7 +19,6 @@ import pino from "../../pino";
2019

2120
expectType<SonicBoom>(destination(""));
2221
expectType<LevelMapping>(levels);
23-
expectType<Logger>(final(pino()));
2422
expectType<MultiStreamRes>(multistream(process.stdout));
2523
expectType<SerializedError>(stdSerializers.err({} as any));
2624
expectType<string>(stdTimeFunctions.isoTime());

0 commit comments

Comments
 (0)
Please sign in to comment.