What is @types/pino?
@types/pino provides TypeScript type definitions for the Pino logging library, which is a fast and low-overhead logging library for Node.js applications.
What are @types/pino's main functionalities?
Basic Logging
This feature allows you to create a basic logger instance and log messages at the 'info' level.
const pino = require('pino');
const logger = pino();
logger.info('Hello, world!');
Custom Log Levels
This feature allows you to define custom log levels for more granular logging.
const pino = require('pino');
const logger = pino({
customLevels: {
foo: 35
}
});
logger.foo('This is a custom log level');
Child Loggers
This feature allows you to create child loggers that inherit properties from the parent logger.
const pino = require('pino');
const logger = pino();
const child = logger.child({ a: 'property' });
child.info('Hello from child logger');
Log Redaction
This feature allows you to redact sensitive information from logs.
const pino = require('pino');
const logger = pino({
redact: ['req.headers.authorization']
});
logger.info({ req: { headers: { authorization: 'secret' } } }, 'Request received');
Other packages similar to @types/pino
@types/winston
@types/winston provides TypeScript type definitions for the Winston logging library, which is a versatile and widely-used logging library for Node.js. Winston offers features like multiple transports, log levels, and formatters, making it a more feature-rich but potentially slower alternative to Pino.
@types/bunyan
@types/bunyan provides TypeScript type definitions for the Bunyan logging library, which is another fast and JSON-based logging library for Node.js. Bunyan offers features like log streams and serializers, making it similar in performance to Pino but with a different API and feature set.
Installation
npm install --save @types/pino
Summary
This package contains type definitions for pino (https://github.com/pinojs/pino.git).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pino.
Additional Details
Credits
These definitions were written by Peter Snider (https://github.com/psnider), BendingBender (https://github.com/BendingBender), Christian Rackerseder (https://github.com/screendriver), GP (https://github.com/paambaati), Alex Ferrando (https://github.com/alferpal), Oleksandr Sidko (https://github.com/mortiy), Harris Lummis (https://github.com/lummish), Raoul Jaeckel (https://github.com/raoulus), Cory Donkin (https://github.com/Cooryd), Adam Vigneaux (https://github.com/AdamVig), and Austin Beer (https://github.com/austin-beer).