npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@batkit/logger-pino

v1.0.1

Published

Pino.js implementation of @batkit/logger facade for Node.js and browser

Downloads

88

Readme

@batkit/logger-pino

Pino.js implementation of the @batkit/logger facade for high-performance logging in Node.js and browser.

Installation

npm install @batkit/logger-pino pino

For development with pretty printing:

npm install --save-dev pino-pretty

Overview

A high-performance LoggerProvider implementation using Pino, one of the fastest Node.js loggers available. Implements the @batkit/logger LoggerProvider interface for seamless integration with the Better Application Toolkit.

Features

  • ✅ Extremely fast (built on Pino)
  • ✅ Works in Node.js and browsers (Pino has browser support)
  • ✅ Structured JSON logging
  • ✅ Low overhead
  • ✅ Named child loggers via getLogger(name)
  • ✅ Full Pino config (redaction, transports, pretty printing) passed straight through
  • ✅ TypeScript-first

Usage

Basic Usage

import { LoggerFacade } from "@batkit/logger";
import { PinoLoggerProvider } from "@batkit/logger-pino";

LoggerFacade.setProvider(new PinoLoggerProvider({ level: "info" }));

const logger = LoggerFacade.getLogger("my-app");

logger.info("Application started");
logger.warn("Low disk space", { available: "10GB" });
logger.error(new Error("Connection timeout"), "Database connection failed");

Development Mode (Pretty Output)

PinoLoggerProvider's constructor takes Pino's own LoggerOptions directly — configure transport for pino-pretty the same way you would with plain Pino:

import { PinoLoggerProvider } from "@batkit/logger-pino";

const provider = new PinoLoggerProvider({
  level: "debug",
  transport: {
    target: "pino-pretty",
    options: { colorize: true, ignore: "pid,hostname" },
  },
});

Redacting Sensitive Data

import { PinoLoggerProvider } from "@batkit/logger-pino";

const provider = new PinoLoggerProvider({
  level: "info",
  redact: {
    paths: ["password", "req.headers.authorization"],
    censor: "[REDACTED]",
  },
});

provider.getLogger("api").info("User data", {
  username: "john",
  password: "secret", // shows as '[REDACTED]'
});

Named (Child) Loggers

import { PinoLoggerProvider } from "@batkit/logger-pino";

const provider = new PinoLoggerProvider({ level: "info" });

const authLogger = provider.getLogger("auth");
const usersLogger = provider.getLogger("users");

authLogger.info("Login attempt"); // pino child logger name: "auth"
usersLogger.info("User created"); // pino child logger name: "users"

Wrapping a Pino Instance Directly

adaptPinoToBatkitLogger wraps an existing Pino Logger/child logger into the @batkit/logger Logger interface, if you're managing the Pino instance yourself instead of going through PinoLoggerProvider:

import { adaptPinoToBatkitLogger } from "@batkit/logger-pino";
import { pino } from "pino";

const pinoRoot = pino({ level: "info" });
const logger = adaptPinoToBatkitLogger(pinoRoot.child({ name: "worker" }));

logger.info("Processing job", { jobId: "42" });

API Reference

Classes

PinoLoggerProvider

Implements @batkit/logger's LoggerProvider interface on top of Pino.

new PinoLoggerProvider(config?: LoggerOptions) // LoggerOptions from "pino"

Methods:

  • getLogger(name: string): Logger — returns a @batkit/logger Logger backed by pino().child({ name })
  • isLogLevelEnabled(level: LogLevel): boolean — checks "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL" against the root Pino logger

Functions

adaptPinoToBatkitLogger(pinoChild: PinoLogger): Logger

Wraps a Pino Logger (or child logger) instance into the @batkit/logger Logger interface. PinoLoggerProvider.getLogger uses this internally.

Integration with Express

Use logContextMiddleware with ContextualLoggerProvider from @batkit/logger/async-local so correlation fields flow into Pino output:

import { LoggerFacade } from "@batkit/logger";
import { ContextualLoggerProvider } from "@batkit/logger/async-local";
import { PinoLoggerProvider } from "@batkit/logger-pino";
import { logContextMiddleware } from "@batkit/express-middleware";
import express from "express";
import { randomUUID } from "node:crypto";

LoggerFacade.setProvider(new ContextualLoggerProvider(new PinoLoggerProvider({ level: "info" })));

const app = express();
app.use(
  logContextMiddleware({
    initialContext: (req) => ({ requestId: req.get("x-request-id") ?? randomUUID() }),
  }),
);

app.get("/users", (req, res) => {
  LoggerFacade.getLogger("api").info("Fetching users list");
  res.json({ users: [] });
});

Performance

Pino is one of the fastest loggers for Node.js:

  • Asynchronous logging by default
  • Minimal overhead
  • Fast JSON serialization
  • Optimized for high-throughput applications

Browser Support

Pino includes browser support out of the box. The same API works in both Node.js and browser environments, though features like transports and file logging are Node.js-specific.

Best Practices

  1. Pass transport: { target: "pino-pretty", ... } in development for readable output
  2. Leave transport unset in production for structured JSON logs
  3. Redact sensitive data using Pino's redact option
  4. Use getLogger(name) to scope logs per module/component
  5. Avoid string interpolation — use structured logging instead

Learn More

Links

License

MIT © Ken Courville