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

ts-log

v3.0.2

Published

Abstract logger TypeScript interface with a dummy logger that does nothing, useful for libraries.

Readme

ts-log

CI Downloads Version License StackGrit Score

A zero-dependency TypeScript logger interface. Let library consumers choose their own logger — or stay silent by default.

Installation

npm install ts-log

Usage

Accept a Logger in your library's constructor, defaulting to dummyLogger (which does nothing):

import { Logger, dummyLogger } from "ts-log";

class MyService {
  constructor(private readonly logger: Logger = dummyLogger) {}

  doWork() {
    this.logger.info("work started");
    // ...
    this.logger.debug("details", { foo: "bar" });
  }
}

Consumers can then pass in any compatible logger — or leave the default:

// silent by default
const service = new MyService();

// or use the built-in console
const service = new MyService(console);

// or use pino, bunyan, winston, etc.
import pino from "pino";
const service = new MyService(pino());

Logger Interface

The interface mirrors console — five methods, each accepting a message and optional parameters:

interface Logger {
  trace(message?: any, ...optionalParams: any[]): void;
  debug(message?: any, ...optionalParams: any[]): void;
  info(message?: any, ...optionalParams: any[]): void;
  warn(message?: any, ...optionalParams: any[]): void;
  error(message?: any, ...optionalParams: any[]): void;
}

Any object matching this shape works — no adapters needed. This includes console, pino, bunyan, winston, and most other Node.js loggers.

Custom Logger

You can implement the interface directly for custom behavior:

import fs from "node:fs";
import { Logger } from "ts-log";

class FileLogger implements Logger {
  private readonly fd: number;

  constructor(filename: string) {
    this.fd = fs.openSync(filename, "a");
  }

  trace(message?: any, ...params: any[]) {
    this.write("TRACE", message, params);
  }
  debug(message?: any, ...params: any[]) {
    this.write("DEBUG", message, params);
  }
  info(message?: any, ...params: any[]) {
    this.write("INFO", message, params);
  }
  warn(message?: any, ...params: any[]) {
    this.write("WARN", message, params);
  }
  error(message?: any, ...params: any[]) {
    this.write("ERROR", message, params);
  }

  private write(level: string, message: any, params: any[]) {
    fs.writeSync(this.fd, `${new Date().toISOString()} ${level} ${message} ${JSON.stringify(params)}\n`);
  }
}

v3 Migration

v3 is a tooling modernization — the Logger interface and dummyLogger API are unchanged.

  • Dual CJS/ESM package (via exports field).
  • "type": "module" added to package.json.
  • Minimum Node.js version is 20.
  • Build output moved from build/src/ to dist/.

License

MIT