From cd09737e6231afd78a0f513ffa312bd7e74c98c2 Mon Sep 17 00:00:00 2001 From: MacFJA Date: Mon, 23 Sep 2024 13:12:22 +0200 Subject: [PATCH] doc: Add Transport @macfja/pino-fingers-crossed (#2047) --- docs/transports.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/transports.md b/docs/transports.md index b1411491a..0e45730e3 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -426,6 +426,7 @@ PRs to this document are welcome for any new transports! + [pino-logfmt](#pino-logfmt) + [pino-telegram-webhook](#pino-telegram-webhook) + [pino-yc-transport](#pino-yc-transport) ++ [@macfja/pino-fingers-crossed](#macfja-pino-fingers-crossed) ### Legacy @@ -1119,6 +1120,29 @@ logger.error(new Error("error")); logger.fatal("fatal"); ``` + +### @macfja/pino-fingers-crossed + +[@macfja/pino-fingers-crossed](https://github.com/MacFJA/js-pino-fingers-crossed) is a Pino v7+ transport that holds logs until a log level is reached, allowing to only have logs when it matters. + +```js +const pino = require('pino'); +const { default: fingersCrossed, enable } = require('@macfja/pino-fingers-crossed') + +const logger = pino(fingersCrossed()); + +logger.info('Will appear immedialty') +logger.error('Will appear immedialty') + +logger.setBindings({ [enable]: 50 }) +logger.info('Will NOT appear immedialty') +logger.info('Will NOT appear immedialty') +logger.error('Will appear immedialty as well as the 2 previous messages') // error log are level 50 +logger.info('Will NOT appear') +logger.info({ [enable]: false }, 'Will appear immedialty') +logger.info('Will NOT appear') +``` + ## Communication between Pino and Transports Here we discuss some technical details of how Pino communicates with its [worker threads](https://nodejs.org/api/worker_threads.html).