Pino
Pino is a super fast, all-natural JSON logger for Node.js. The current stable version is 10.3.1. The library is actively maintained with frequent minor releases, typically addressing bug fixes, performance improvements, and feature enhancements for its core logging and transport functionalities.
Common errors
-
ERR_WORKER_INVALID_EXEC_ARGV
cause Using Pino transports in worker threads with specific monitoring tools or `NODE_OPTIONS` preload configurations.fixUpgrade to Pino v10.2.1 or newer. Ensure Node.js environment variables (like `NODE_OPTIONS`) are correctly sanitized or avoid conflicting preload settings when using worker-based transports. -
TypeError: Argument of type '...' is not assignable to parameter of type '(...)'
cause Pino v10.1.0 introduced stricter type definitions for the `censor` function signature, leading to TypeScript compilation errors for older, less safe implementations.fixAdjust the signature of your `censor` function to align with the updated, safer types provided by Pino v10.1.0 and later. Consult the Pino redaction documentation for the correct signature.
Warnings
- breaking Pino v10 drops support for Node.js 18.
- breaking The type signature for the `censor` function used in redaction has been updated for improved safety, potentially causing TypeScript errors or runtime issues if using previous, less safe types.
- gotcha When using Pino transports in worker threads, certain Node.js monitoring tools or `--import` preload options can lead to `ERR_WORKER_INVALID_EXEC_ARGV` errors or memory leaks.
- gotcha Pino's transport level filtering behavior might not be immediately intuitive. Logs are filtered by the transport's level, not necessarily the parent logger's level.
Install
-
npm install pino -
yarn add pino -
pnpm add pino
Imports
- pino
import pino from 'pino'
Quickstart
import pino from 'pino';
const logger = pino();
logger.info('hello world');
const child = logger.child({ a: 'property' });
child.info('hello child!');