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

@azlib/logger

v0.2.0

Published

A lightweight, fast, structured logger for Node.js. Log calls are synchronous ring-buffer pushes — zero format or I/O work on the calling thread. Drain and transport I/O happen asynchronously on `process.nextTick`.

Readme

@azlib/logger

A lightweight, fast, structured logger for Node.js. Log calls are synchronous ring-buffer pushes — zero format or I/O work on the calling thread. Drain and transport I/O happen asynchronously on process.nextTick.

Installation

pnpm add @azlib/logger
# Optional: SQLite adapter peer dependency
pnpm add better-sqlite3

Quick Start

import { createLogger, createConsoleTransport } from "@azlib/logger";

const logger = createLogger({
  level: "info",
  transports: [createConsoleTransport()],
});

logger.info("Application started", { port: 3000 });
logger.warn("High memory", { usedMb: 512 });

await logger.close();

Entry Points

| Import path | Contents | |---|---| | @azlib/logger | Core logger, transports, and formats | | @azlib/logger/adapters/sqlite | Optional SQLite DatabaseAdapter | | @azlib/logger/dashboard | In-process HTTP dashboard transport |

API Reference

createLogger(options: LoggerOptions): Logger

const logger = createLogger({
  level: "info",             // Minimum log level
  transports: [...],         // One or more transports
  format: jsonFormat(),      // Optional global format
  bindings: { service: "api" }, // Root-level context fields
  buffer: {
    maxSize: 1024,           // Ring buffer capacity (records), default 1024
    overflow: "drop-oldest", // "drop" | "drop-oldest" | "throw"
  },
});

Logger methods: trace, debug, info, warn, error, fatal, child, flush, close.

Child loggers

const reqLogger = logger.child({ requestId: "abc-123" });
reqLogger.info("Handling request"); // includes requestId in every record

Bindings are serialised once at child-creation time — no per-call allocation.

Transports

createConsoleTransport(options?)

createConsoleTransport({
  splitStreams: true,  // warn/error/fatal → stderr; others → stdout (default: true)
  format: prettyFormat({ colors: true }), // per-transport format override
})

createFileTransport(options)

createFileTransport({
  filePath: "./logs/app.log", // parent directory created if missing
  bufferSize: 4096,           // write buffer bytes (default: 4096)
})

createDatabaseTransport(options)

createDatabaseTransport({
  adapter,           // any DatabaseAdapter
  batchSize: 100,    // flush when this many records accumulate (default: 100)
  flushInterval: 5000, // flush every N ms even if batchSize not reached (default: 5000)
})

Formats

import { jsonFormat, prettyFormat, combineFormats } from "@azlib/logger";

jsonFormat()           // newline-delimited JSON
prettyFormat({
  colors: true,        // auto-detected from TTY by default
  showPid: false,
})

// Chain multiple transforms; null short-circuits the chain
combineFormats(redactSecrets, jsonFormat())

Custom format:

const redactFormat = {
  transform: (record) => ({ ...record, meta: { ...record.meta, password: undefined } }),
};

SQLite adapter

import { createSqliteAdapter } from "@azlib/logger/adapters/sqlite";
import { createLogger, createDatabaseTransport } from "@azlib/logger";

const adapter = createSqliteAdapter({ filePath: "./logs.db" });

const logger = createLogger({
  level: "info",
  transports: [createDatabaseTransport({ adapter })],
});

// Query stored logs
const errors = await adapter.query({ minLevel: 50, limit: 100 });

Dashboard

import { createDashboardTransport } from "@azlib/logger/dashboard";

const dashboard = createDashboardTransport({
  config: { port: 8999 },
});

const logger = createLogger({
  level: "debug",
  transports: [dashboard],
});

// Visit http://127.0.0.1:8999/logs/ui in your browser

The dashboard binds to 127.0.0.1 only and is intended for local development.

Overflow Policy

When the ring buffer is full, the overflow option controls behaviour:

| Policy | Behaviour | |---|---| | drop | Silently discard the incoming record. Increments droppedCount. | | drop-oldest | Evict the oldest buffered record to make room (default). | | throw | Throw LogBufferFullError on the calling thread. |

Performance

  • logger.info() is a synchronous ring-buffer append — no format, no I/O.
  • Child bindings are JSON-serialised once at construction, never per-call.
  • Drain runs via process.nextTick, keeping the event loop responsive.
  • Benchmark: 100k logger.info() calls in < 2s wall time on a standard laptop.

Custom transport

import type { Transport } from "@azlib/logger";

const myTransport: Transport = {
  name: "my-transport",
  options: {},
  write(record) { /* sync or async */ },
  flush: async () => { /* drain buffers */ },
  close: async () => { /* shutdown */ },
};