class PinoLogger
implements ILogger
Since 0.1.0

Structured logger backed by Pino.

Because the npm:pino import is async, use PinoLogger.create (async factory) rather than new. An injected pinoFactory option allows synchronous construction for tests.

Examples

Async construction (real Pino)

const logger = await PinoLogger.create({ level: 'debug', redact: ['password'] });
logger.info('server started', { port: 3000 });

Injected factory (tests)

const logger = await PinoLogger.create({
  level: 'info',
  pinoFactory: (opts) => fakePino,
});

Static Methods

Asynchronously creates a PinoLogger.

When pinoFactory is provided in options, the factory is called synchronously and no import is performed. Otherwise, Pino is loaded via await import('npm:pino@10.x').

Properties

readonly
level: LogLevel

The minimum level this logger emits.

Methods

child(bindings: LogMetadata): ILogger

Returns a child logger backed by Pino's native child().

debug(
message: string,
metadata?: LogMetadata
): void

Logs at debug severity.

error(
message: string,
metadata?: LogMetadata
): void

Logs at error severity.

fatal(
message: string,
metadata?: LogMetadata
): void

Logs at fatal severity.

info(
message: string,
metadata?: LogMetadata
): void

Logs at info severity.

trace(
message: string,
metadata?: LogMetadata
): void

Logs at trace severity.

warn(
message: string,
metadata?: LogMetadata
): void

Logs at warn severity.