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

@alexpricedev/log-digest

v0.1.0

Published

In-memory log buffer with pluggable digest delivery for Bun apps

Readme

@alexpricedev/log-digest

In-memory log buffer with a pluggable digest sink. Buffers error / warn / info entries as they happen, then — on an interval you control — hands them off to a sink of your choosing (email, Slack, webhook, anywhere). Zero runtime dependencies. Bun only.

Install

bun add @alexpricedev/log-digest

Quick start

import {
  logError,
  logInfo,
  startDigestScheduler,
  type DigestSink,
} from "@alexpricedev/log-digest";

const emailSink: DigestSink = {
  async send({ format, summary, period }) {
    await sendEmail({
      to: "[email protected]",
      subject: `Log digest — ${period} — ${summary.errorCount} errors`,
      html: format.html,
      text: format.text,
    });
  },
};

startDigestScheduler({ sink: emailSink });

logInfo("boot", "server started");
logError("payments", "charge failed", { orderId: "abc123" });

Entries are also mirrored to console.log / console.warn / console.error as they happen, so you still see them in your normal stdout/stderr stream.

How it works

  • Every log* call appends a LogEntry to an in-memory buffer.
  • Every intervalMs (default: 1 hour) the scheduler calls drainLogs() and hands the result to your sink.
  • formatDigest() renders a styled HTML table + a plain-text summary, both available on payload.format.
  • If your sink throws, the error and the logs that would have been sent are written to console.error. The scheduler keeps running.

API

Logging

log(level, category, message, data?): void
logError(category, message, data?): void
logWarn(category, message, data?): void
logInfo(category, message, data?): void

Buffer

drainLogs(): LogEntry[]     // returns + clears the buffer
getBufferSize(): number

Formatting

formatDigest(logs: LogEntry[]): { html: string; text: string }

Scheduler

startDigestScheduler({
  sink,                 // DigestSink
  intervalMs?: number,  // default 3_600_000 (1h)
  startupDelayMs?: number, // default 5000 (ms after start for a first flush; 0 disables)
}): void

stopDigestScheduler(): void
processDigest(sink: DigestSink): Promise<void>  // manual flush

Sink contract

interface DigestSink {
  send(payload: DigestPayload): Promise<void>;
}

interface DigestPayload {
  logs: LogEntry[];
  summary: { errorCount: number; warnCount: number; infoCount: number };
  period: string;                            // e.g. "2026-04-21 18:00 UTC"
  format: { html: string; text: string };
}

Example sinks

Slack webhook

const slackSink: DigestSink = {
  async send({ summary, period, format }) {
    await fetch(process.env.SLACK_WEBHOOK_URL!, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        text: `Log digest — ${period}\n${summary.errorCount} errors, ${summary.warnCount} warnings, ${summary.infoCount} info\n\n${format.text}`,
      }),
    });
  },
};

HTTP webhook (raw payload)

const httpSink: DigestSink = {
  async send(payload) {
    await fetch("https://hooks.example.com/logs", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(payload),
    });
  },
};

Testing in your app

The buffer is module-level singleton state. In tests, call drainLogs() in beforeEach/afterEach for isolation. Pass a recording sink to processDigest to assert on payload contents without starting the scheduler.

License

MIT