@kaapi/logger-pino
v0.0.51
Published
A customized Pino logger wrapper featuring predefined 'silly' and 'verbose' log levels.
Maintainers
Readme
@kaapi/logger-pino
A high-performance Pino logger adapter custom-built for the Kaapi framework. This package extends the blazing-fast pino logger to seamlessly implement Kaapi's ILogger interface, instantly provisioning your application with unified logging capabilities including native silly and verbose levels.
✨ Features
- Extended Log Levels: Seamlessly adds silly (5) and verbose (15) methods alongside standard Pino levels.
- Full Pino Ecosystem Support: Retains raw access to Pino configurations, streams, ecosystem plugins, and transports.
- Strict Type Safety: Extensible TypeScript support allowing you to still supply your own additional runtime custom levels.
🚀 Getting Started
Installation
npm install @kaapi/logger-pino pino @kaapi/loggerBasic Setup
Pass the initialized logger directly into the Kaapi application constructor configuration:
import { Kaapi } from '@kaapi/kaapi';
import { createPinoLogger } from '@kaapi/logger-pino';
const app = new Kaapi({
logger: createPinoLogger({}),
});
app.log.info('Using Pino to log');
app.log.silly('This is a highly detailed silly trace log!');Advanced Custom Levels
If you need to introduce extra custom levels beyond the built-in silly and verbose options, import the internalCustomLevels object. This ensures your custom settings merge seamlessly with Kaapi's defaults without overwriting them:
import { createPinoLogger, internalCustomLevels } from '@kaapi/logger-pino';
// Define your custom type constraints so TypeScript catches typo errors
type ExtendedLevels = 'notice' | 'alert';
const log = createPinoLogger<ExtendedLevels>({
customLevels: {
...internalCustomLevels,
notice: 35,
alert: 55,
},
});
log.info('Standard log message');
log.silly('Kaapi built-in level');
log.notice('Your new notice log level!');
log.alert('Your new alert log level!');Usage with pino-pretty
import { createPinoLogger } from '@kaapi/logger-pino';
const log = createPinoLogger({
level: 'trace',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
customLevels: 'verbose:25',
customColors: 'verbose:cyan',
useOnlyCustomProps: false,
},
},
});
log.silly('Silly log');
log.trace('Trace log');
log.debug('Debug log');
log.verbose('Verbose log');
log.info('Info log');
log.warn('Warn log');
log.error('Error log');
log.fatal('Fatal log');