diff --git a/docs/api.md b/docs/api.md
index 2cf0c6c77..7c2a78405 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -24,7 +24,6 @@
* [Statics](#statics)
* [pino.destination()](#pino-destination)
* [pino.transport()](#pino-transport)
- * [pino.final()](#pino-final)
* [pino.multistream()](#pino-multistream)
* [pino.stdSerializers](#pino-stdserializers)
* [pino.stdTimeFunctions](#pino-stdtimefunctions)
@@ -1150,59 +1149,6 @@ For more on transports, how they work, and how to create them see the [`Transpor
* `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.
* `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`.
-
-
-### `pino.final(logger, [handler]) => Function | FinalLogger`
-
-__The use of `pino.final` is discouraged in Node.js v14+ and not required.
-It will be removed in the next major version.__
-
-The `pino.final` method can be used to acquire a final logger instance
-or create an exit listener function. This is _not_ needed in Node.js v14+
-as pino automatically can handle those.
-
-The `finalLogger` is a specialist logger that synchronously flushes
-on every write. This is important to guarantee final log writes,
-when using `pino.destination({ sync: false })` target.
-
-Since final log writes cannot be guaranteed with normal Node.js streams,
-if the `destination` parameter of the `logger` supplied to `pino.final`
-is a Node.js stream `pino.final` will throw.
-
-The use of `pino.final` with `pino.destination` is not needed, as
-`pino.destination` writes things synchronously.
-
-#### `pino.final(logger, handler) => Function`
-
-In this case the `pino.final` method supplies an exit listener function that can be
-supplied to process exit events such as `exit`, `uncaughtException`,
-`SIGHUP` and so on.
-
-The exit listener function will call the supplied `handler` function
-with an error object (or else `null`), a `finalLogger` instance followed
-by any additional arguments the `handler` may be called with.
-
-```js
-process.on('uncaughtException', pino.final(logger, (err, finalLogger) => {
- finalLogger.error(err, 'uncaughtException')
- process.exit(1)
-}))
-```
-
-#### `pino.final(logger) => FinalLogger`
-
-In this case the `pino.final` method returns a finalLogger instance.
-
-```js
-var finalLogger = pino.final(logger)
-finalLogger.info('exiting...')
-```
-
-* See [`destination` parameter](#destination)
-* See [Exit logging help](/docs/help.md#exit-logging)
-* See [Asynchronous logging ⇗](/docs/asynchronous.md)
-* See [Log loss prevention ⇗](/docs/asynchronous.md#log-loss-prevention)
-
### `pino.multistream(streamsArray, opts) => MultiStreamRes`
diff --git a/docs/help.md b/docs/help.md
index a042a63f6..6cac1c0f9 100644
--- a/docs/help.md
+++ b/docs/help.md
@@ -289,35 +289,3 @@ log.info({ msg: 'mapped to originalMsg' }, 'a message')
// {"level":30,"time":1596313323106,"pid":63739,"hostname":"foo","msg":"no original message"}
// {"level":30,"time":1596313323107,"pid":63739,"hostname":"foo","msg":"a message","originalMsg":"mapped to originalMsg"}
```
-
-
-## Exit logging (deprecated for Node v14+)
-
-__In pino v7, The following piece of documentation is not needed in Node v14+ and it will
-emit a deprecation notice.__
-
-When a Node process crashes from uncaught exception, exits due to a signal,
-or exits of it's own accord we may want to write some final logs – particularly
-in cases of error.
-
-Writing to a Node.js stream on exit is not necessarily guaranteed, and naively writing
-to an asynchronous logger on exit will definitely lead to lost logs.
-
-To write logs in an exit handler, create the handler with [`pino.final`](/docs/api.md#pino-final):
-
-```js
-process.on('uncaughtException', pino.final(logger, (err, finalLogger) => {
- finalLogger.error(err, 'uncaughtException')
- process.exit(1)
-}))
-
-process.on('unhandledRejection', pino.final(logger, (err, finalLogger) => {
- finalLogger.error(err, 'unhandledRejection')
- process.exit(1)
-}))
-```
-
-The `finalLogger` is a special logger instance that will synchronously and reliably
-flush every log line. This is important in exit handlers, since no more asynchronous
-activity may be scheduled.
-
diff --git a/lib/tools.js b/lib/tools.js
index 29bf28107..3ac99c739 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -298,9 +298,6 @@ function createArgsNormalizer (defaultOptions) {
throw new Error('prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)')
}
- if ('onTerminated' in opts) {
- throw Error('The onTerminated option has been removed, use pino.final instead')
- }
const { enabled } = opts
if (enabled === false) opts.level = 'silent'
if (!stream) {
diff --git a/pino.d.ts b/pino.d.ts
index a977a1c8e..6ad74ba38 100644
--- a/pino.d.ts
+++ b/pino.d.ts
@@ -746,20 +746,6 @@ declare namespace pino {
streamsArray: (DestinationStream | StreamEntry)[] | DestinationStream | StreamEntry,
opts?: MultiStreamOptions
): MultiStreamRes
-
- /**
- * The pino.final method can be used to create an exit listener function.
- * This listener function can be supplied to process exit events.
- * The exit listener function will call the handler with
- * @param [logger]: pino logger that serves as reference for the final logger
- * @param [handler]: Function that will be called by the handler returned from this function
- * @returns Exit listener function that can be supplied to process exit events and will call the supplied handler function
- */
- export function final(
- logger: Logger,
- handler: (error: Error, finalLogger: Logger, ...args: any[]) => void,
- ): (error: Error | null, ...args: any[]) => void;
- export function final(logger: Logger): Logger;
}
//// Callable default export
@@ -785,7 +771,6 @@ declare function pino(options: Options, stream: D
export const destination: typeof pino.destination;
export const transport: typeof pino.transport;
export const multistream: typeof pino.multistream;
-export const final: typeof pino.final;
export const levels: typeof pino.levels;
export const stdSerializers: typeof pino.stdSerializers;
export const stdTimeFunctions: typeof pino.stdTimeFunctions;
diff --git a/test/types/pino-top-export.test-d.ts b/test/types/pino-top-export.test-d.ts
index 250421791..9efd8c494 100644
--- a/test/types/pino-top-export.test-d.ts
+++ b/test/types/pino-top-export.test-d.ts
@@ -3,7 +3,6 @@ import type { SonicBoom } from "sonic-boom";
import {
destination,
- final,
LevelMapping,
levels,
Logger,
@@ -20,7 +19,6 @@ import pino from "../../pino";
expectType(destination(""));
expectType(levels);
-expectType(final(pino()));
expectType(multistream(process.stdout));
expectType(stdSerializers.err({} as any));
expectType(stdTimeFunctions.isoTime());