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

@klazapp/typescript-logger

v0.1.1

Published

Tiny namespaced logger + auto-proxy wrapper + decorator, with global toggles.

Readme

Klazapp React Logger

A tiny, flexible TypeScript logger for React and Node.js projects.
It provides namespaced logging, global toggles, and automatic instrumentation via proxies and decorators.


⭐ Why use this?

Most projects begin with console.log. It works initially, but problems appear as the codebase grows:

  • Logs become inconsistent and difficult to search
  • Debug messages mix with warnings and errors
  • Enabling or disabling logs requires code edits and redeployment
  • Sensitive data may be exposed if not manually redacted

Klazapp React Logger addresses these issues with structured, configurable, and production-ready logging.


🔍 Comparison

| Aspect | console.log | React Logger | |-------------------------|-------------------------------------|-------------------------------------------------------| | Control | Hardcoded, requires code edits | Runtime toggle via DEBUG env var or localStorage.debug | | Organization | Scattered, inconsistent | Namespaced by feature/service | | Levels | None (all logs look the same) | debug, info, warn, error | | Instrumentation | Manual, repetitive | Automatic via withDebugProxy or @DebugLog decorator | | Safety | Risk of leaking sensitive data | Redaction options for args and results | | Production | All logs bundled | Debug logs removable via dead-code elimination |


✅ Key benefits

  • Global enable/disable toggle: turn debug logs on or off at runtime without modifying source code
  • Namespaced logs: group logs by feature or service (UserService, Auth, PaymentFlow)
  • Log levels: structured severity categories (debug, info, warn, error)
  • Automatic instrumentation:
    • Wrap objects with withDebugProxy to capture all method calls
    • Apply @DebugLog for fine-grained, per-method logging
  • Safe logging: redact arguments or results to prevent sensitive data exposure
  • Dead-code elimination: remove debug logs from production bundles to minimize size and risk
  • Cross-environment compatibility: consistent usage in React frontend, Node backend, and shared libraries

📦 Installation

From npm

npm i @klazapp/react-logger

From GitHub

npm i github:klazapp/react-logger

🚀 Usage

1. Manual logging with namespaces

import { makeLogger } from "@klazapp/react-logger";

const log = makeLogger("UserService");

log.debug("fetching user", { id: 123 });
log.info("User created successfully");
log.warn("Retrying after failure");
log.error("Unexpected error", new Error("Oops"));

Output:

[UserService:debug] fetching user { id: 123 }
[UserService:info] User created successfully
[UserService:warn] Retrying after failure
[UserService:error] Unexpected error Error: Oops

2. Automatic logging with proxies

Wrap any service or object and log all method calls automatically:

import { withDebugProxy } from "@klazapp/react-logger";

class UserService {
  async getUser(id: string) {
    return { id, name: "Alice" };
  }
}

const userService = withDebugProxy(new UserService(), "UserService");

await userService.getUser("123");

Output:

[UserService.getUser:debug] → called with ["123"]
[UserService.getUser:debug] ← resolved with {"id":"123","name":"Alice"}

3. Method decorators (TypeScript only)

Enable decorators in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true
  }
}

Then use the @DebugLog decorator:

import { DebugLog } from "@klazapp/react-logger";

class PaymentService {
  @DebugLog()
  async processPayment(amount: number) {
    if (amount > 100) throw new Error("Limit exceeded");
    return { ok: true, amount };
  }
}

const service = new PaymentService();
await service.processPayment(50);
await service.processPayment(200).catch(() => {});

Output:

[PaymentService.processPayment:debug] → called with [50]
[PaymentService.processPayment:debug] ← resolved with {"ok":true,"amount":50}

[PaymentService.processPayment:debug] → called with [200]
[PaymentService.processPayment:error] ✖ threw Error: Limit exceeded

⚙️ Controlling logs

In Node.js

Enable namespaces with the DEBUG env variable:

DEBUG="UserService,PaymentService" node app.js

Enable all:

DEBUG="*"

In the browser

Set it in DevTools console:

localStorage.debug = "UserService,*";

Then refresh the page.


🛠 Advanced features

  • Opt-out noisy methods:

    const wrapped = withDebugProxy(service, "Service", {
      optOut: (method) => ["pollingLoop"].includes(method),
    });
  • Redact sensitive data:

    withDebugProxy(service, "Auth", {
      redactArgs: (args) => ["***"],
    });

📖 Roadmap

  • [ ] Structured JSON logs
  • [ ] Browser-friendly pretty output
  • [ ] Optional log shipping to backend

📜 License

MIT © Klazapp