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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bonsay

v1.0.0

Published

Lightweight logger plugin

Readme

Bonsay

A lightweight & expressive logger for modern JavaScript runtimes.

npm version License: MIT

A minimalistic yet powerful logger. Inspired by the craft of Bonsai — precise, elegant, controlled — and the simplicity of Say — clean, expressive logging.


Features

  • Ultra-lightweight, zero dependencies

  • JSON logs (production)

  • Pretty logs (development)

    • Inline view → msg key=value
    • Expanded view → msg\n{ json }
  • Timestamp modes (ISO, epoch, or disabled)

  • Custom timestamp formats (YYYY-MM-DD HH:mm:ss, etc.)

  • Field redaction ([REDACTED])

  • Field exclusion (remove entirely from logs)

  • Namespaces (e.g., "api", "db")

  • Base fields injected into every log

  • Works everywhere:

    • Node
    • Bun
    • Deno
    • Browsers
    • Cloudflare Workers
    • Any framework (Express, Fastify, Hono, Elysia, Fwoom…)

Installation

npm install bonsay
# or
pnpm add bonsay
# or
yarn add bonsay

Basic Usage

import { createLogger } from "bonsay";

const log = createLogger({ level: "debug" });

log.info("Server started");
log.debug("Debug details", { port: 3000 });

JSON Mode

const log = createLogger({ pretty: false });
log.info("Started", { port: 3000 });

Outputs:

{"msg":"Started","level":"info","port":3000,"time":"2025-02-10T13:00:00.000Z"}

Pretty Modes

Expanded (default)

createLogger({ pretty: true, prettyStyle: "expanded" });
INFO api User logged in
{
  "success": true,
  "id": 123
}

Inline

createLogger({ pretty: true, prettyStyle: "inline" });
INFO api User logged in success=true id=123

Custom Timestamp Format (Pretty Mode)

createLogger({
  pretty: true,
  timestampFormat: "YYYY-MMM-DD HH:mm:ss Z",
});

Output:

[2025-Feb-10 13:22:11 GMT+7] INFO api Starting service

Supported tokens:

| Token | Meaning | | ------ | ---------------------------- | | YYYY | Year | | MMM | Month short name (Jan, Feb…) | | MM | Month number | | DD | Day | | HH | Hours | | mm | Minutes | | ss | Seconds | | Z | Timezone |


Redact Sensitive Fields

createLogger({
  redactKeys: ["password", "token"]
});

Exclude Fields Completely

createLogger({
  base: { service: "billing", instance: "i-aaa" },
  excludeKeys: ["instance"]
});

Namespaces

const log = createLogger({ namespace: "api" });
const db = log.child({ namespace: "db" });

db.info("Connected");

Express Integration

app.use((req, res, next) => {
  req.log = log.child({
    namespace: "req",
    reqId: Date.now().toString(36),
  });

  req.log.info("Incoming request", { method: req.method });

  res.on("finish", () => {
    req.log.info("Request completed", { status: res.statusCode });
  });

  next();
});

Fwoom Integration (no plugin required)

const log = createLogger({ pretty: true });
app.log = log;

app.onRequest((ctx) => {
  ctx.log = log.child({ reqId: Date.now().toString(36) });
  ctx.log.info("Incoming request");
});

Custom Destination Example

createLogger({
  destination: {
    write(line, level) {
      sendToExternalLogService(line);
    }
  }
});

Contributing

Contributions are welcome! If you'd like to help improve Bonsay, here's how you can get started:

  1. Fork the Repository Visit the GitHub repo and click Fork: https://github.com/sujwn/bonsay

  2. Clone Your Fork

git clone https://github.com/<your-username>/bonsay.git
cd bonsay
  1. Install Dependencies
npm install
  1. Create a Feature Branch
git checkout -b feature/my-improvement
  1. Make Changes Follow the existing coding style and structure.

  2. Run Build & Tests

npm run build
  1. Commit Your Changes
git commit -m "Add feature: my improvement"
  1. Push & Open PR
git push origin feature/my-improvement

Open a Pull Request to main with a clear description.


License

MIT