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

warehouse-of-logs-client

v1.0.2

Published

Client library for the WarehouseOfLogs log aggregation service

Readme

warehouse-of-logs-client

A lightweight TypeScript/JavaScript client for the WarehouseOfLogs log aggregation service. Supports single and batched log ingestion, automatic flushing, log levels, temporary/persistent logs, and metadata.

Also available as a Docker image.

Installation

npm install warehouse-of-logs-client
bun add warehouse-of-logs-client

Quick Start

import { WolClient } from "warehouse-of-logs-client";

const logger = new WolClient({
  collectorUrl: "http://localhost:7001",
  apiKey: "wol_your_api_key_here",
  appName: "my-service",
});

logger.info("User signed in", { metadata: { userId: "abc123" } });
logger.error("Payment failed", { metadata: { orderId: 42 } });

// Flush before exiting
await logger.shutdown();

Constructor Options

| Option | Type | Default | Description | |---|---|---|---| | collectorUrl | string | (required) | Base URL of the collector service | | apiKey | string | (required) | API key for authentication (Bearer token) | | appName | string | — | Default app_name applied to every log. Can be overridden per entry. | | persist | boolean | false | Default retention. false = temporary (auto-expires), true = stored indefinitely. | | expiresIn | number | — | Default TTL in seconds for temporary logs. Server default is 86400 (1 day). | | batchSize | number | 50 | Logs are buffered and sent in batches of this size. Set to 1 to send each log immediately. | | flushInterval | number | 5000 | Max time in ms before the buffer is auto-flushed. |

Logging Methods

Level Shortcuts

The easiest way to log. These buffer logs internally and flush automatically.

logger.info("Server started on port 3000");
logger.warn("Disk usage above 80%");
logger.error("Unhandled exception in /api/users");
logger.debug("Cache miss for key session:abc");

All shortcuts accept an optional second argument to set metadata, persistence, custom app name, or TTL:

logger.info("Order placed", {
  app_name: "orders-service",  // override the default appName
  metadata: { orderId: 123, total: 59.99 },
  persist: true,               // keep this log forever
});

logger.debug("Temp trace", {
  expires_in: 300,  // auto-delete after 5 minutes
});

log(entry)

Add a log to the buffer with full control over all fields:

logger.log({
  app_name: "worker",
  level: "ERROR",
  message: "Job failed after 3 retries",
  timestamp: new Date().toISOString(),  // optional, defaults to now
  metadata: { jobId: "j-99", queue: "emails" },
  persist: true,
});

send(entry) — Immediate (no batching)

Sends a single log directly to the collector, bypassing the buffer. Returns a promise.

await logger.send({
  app_name: "auth-service",
  level: "ERROR",
  message: "Critical: database connection lost",
  persist: true,
});

Flushing & Shutdown

Logs are batched in memory and sent when either batchSize is reached or flushInterval elapses.

// Manually flush buffered logs
const count = await logger.flush();
console.log(`Flushed ${count} logs`);

// Flush + stop the background timer (call before process exit)
await logger.shutdown();

For graceful shutdowns:

process.on("SIGTERM", async () => {
  await logger.shutdown();
  process.exit(0);
});

Log Entry Fields

| Field | Type | Required | Description | |---|---|---|---| | app_name | string | Yes* | Source application name. *Optional if appName is set in the constructor. | | level | "INFO" \| "WARN" \| "ERROR" \| "DEBUG" | Yes | Severity level | | message | string | Yes | Log message (max 10,000 chars) | | timestamp | string | No | ISO 8601 datetime. Defaults to new Date().toISOString(). | | metadata | Record<string, unknown> | No | Arbitrary key-value data attached to the log | | persist | boolean | No | true = permanent, false = temporary (default) | | expires_in | number | No | TTL in seconds for temporary logs. Server default: 86400 (1 day). Ignored when persist is true. |

Temporary vs Persistent Logs

By default, all logs are temporary and expire after 1 day. You can control this at three levels:

// 1. Client-wide defaults
const logger = new WolClient({
  collectorUrl: "http://localhost:7001",
  apiKey: "wol_...",
  appName: "my-app",
  persist: false,      // default: temporary
  expiresIn: 3600,     // default: expire after 1 hour
});

// 2. Per-log override — this one is permanent
logger.info("Deploy succeeded", { persist: true });

// 3. Per-log TTL — expires in 10 minutes
logger.debug("Request trace", { expires_in: 600 });

Priority: per-log persist/expires_in > client defaults > server defaults.

Examples

Express Middleware

import express from "express";
import { WolClient } from "warehouse-of-logs-client";

const app = express();
const logger = new WolClient({
  collectorUrl: "http://localhost:7001",
  apiKey: "wol_...",
  appName: "express-api",
});

app.use((req, res, next) => {
  const start = Date.now();
  res.on("finish", () => {
    logger.info(`${req.method} ${req.path} ${res.statusCode}`, {
      metadata: {
        method: req.method,
        path: req.path,
        status: res.statusCode,
        duration_ms: Date.now() - start,
      },
    });
  });
  next();
});

Error Tracking

process.on("uncaughtException", async (err) => {
  await logger.send({
    app_name: "my-app",
    level: "ERROR",
    message: err.message,
    metadata: { stack: err.stack },
    persist: true,  // keep error logs permanently
  });
  process.exit(1);
});

Batch Worker

const logger = new WolClient({
  collectorUrl: "http://localhost:7001",
  apiKey: "wol_...",
  appName: "batch-worker",
  batchSize: 200,        // send every 200 logs
  flushInterval: 10000,  // or every 10 seconds
  expiresIn: 7200,       // expire after 2 hours
});

for (const job of jobs) {
  logger.debug(`Processing job ${job.id}`);
  // ... process job ...
}

await logger.shutdown();

License

Apache-2.0