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

@typepurify/logger

v0.5.11

Published

Enterprise logging suite.

Readme


npm version

🚀 Overview

@typepurify/logger is a blazing-fast logger designed for backend services. It natively supports JSON serialization (preventing circular reference crashes) and includes middleware for Express.js.

📦 Installation

npm install @typepurify/logger

🛠 Features & Examples

1. Base Logger

Create a logger with JSON or colorized text formatting.

import { Logger } from '@typepurify/logger';

const log = new Logger({
  level: 'info',
  format: 'json', // or 'text'
  colorize: true,
  customColors: { info: '\x1b[36m' }, // Override ANSI colors (v0.5.11 🚀)
});

log.info('Server started', { port: 3000 });
log.error('Database connection failed', new Error('Timeout'));

2. Scoped Loggers

Create child loggers that automatically inherit properties.

import { createScopedLogger } from '@typepurify/logger';

const dbLogger = createScopedLogger(log, 'Database');
dbLogger.info('Query executed', { time: '10ms' });
// Outputs JSON with { "scope": "Database", "time": "10ms" } attached

3. Express Middleware

Automatically log incoming HTTP requests and response times.

import express from 'express';
import { requestLogger } from '@typepurify/logger';

const app = express();
app.use(requestLogger(log));

4. Utilities

  • formatError(err): Beautifully formats stack traces.
  • LogRateLimiter: Prevent your logs from being flooded during high-throughput errors (e.g. while in a retry loop).
  • createFileLogger(path, options): File-backed logger stub.

5. Silent Mode

Easily suppress logs during test environments or specific runs.

const log = new Logger({
  silent: true,
});

🆕 New in v0.5.8

createLogAlertEngine() — Pattern-Based Log Alerting

Fires registered handler callbacks when log messages match defined RegExp rules.

import { createLogAlertEngine } from '@typepurify/logger';

const engine = createLogAlertEngine();
engine.addRule(/ERROR/, (msg) => sendAlert(msg));
engine.evaluate('ERROR: Database unreachable'); // triggers alert
engine.evaluate('INFO: Server started'); // no-op

formatLogWasm(level, message, meta?) — WASM Log Formatter

Fast structured log line formatter with ISO timestamp and meta serialization.

import { formatLogWasm } from '@typepurify/logger';

const line = formatLogWasm('error', 'DB timeout', { db: 'postgres' });
// "[WASM:ERROR] 2026-08-07T... - DB timeout | {"db":"postgres"}"

🛡️ License

MIT © Vallarasu Kanthasamy


📋 Changelog

v0.5.4 — Latest

New Features:

  • injectOpenTelemetryTraceHeader(traceId, spanId) — Generates a W3C-compliant traceparent header object for distributed tracing with OpenTelemetry.
import { injectOpenTelemetryTraceHeader } from '@typepurify/logger';

const headers = injectOpenTelemetryTraceHeader(
  '4bf92f3577b34da6a3ce929d0e0e4736',
  '00f067aa0ba902b7',
);
// => { traceparent: '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01' }

fetch('/api/endpoint', { headers });

Bug Fixes:

  • Added maxBuffer cap to LogRateLimiter to prevent unbounded memory growth during log spikes.

v0.5.1

  • Added silent mode for quiet test environments.
  • Added sanitizeLogMeta to redact sensitive fields (password, token, secret, etc.).
  • Added createNoopLogger for test stubs.
  • Added createScopedLogger for tagged context logging.

0.5.8 Updates

Includes new features.