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

@apihive/logger-facade

v1.0.1

Published

A minimal logging facade: LogLevel, LoggerFacade, and a ConsoleLogger implementation.

Readme

@apihive/logger-facade

A tiny, framework-agnostic logging facade that standardizes how libraries and applications log.

  • Unify logging behind a minimal interface (LoggerFacade + LogLevel).
  • Delegate the actual logging to the library of your choice (pino, winston, console, etc.).
  • Swap or configure loggers per environment without changing your code.

The core idea: any app/module using this facade delegates logging to a single, unified logger chosen by the project. Libraries depend on the facade – applications decide which logger implementation to plug in.

Why this package?

  • Consistency: Libraries and modules don’t need to pick a logging engine. They depend on the facade; your application provides the implementation.
  • Flexibility: Swap implementations (console in the browser, pino in Node, mocked logger in tests) without refactoring call sites.
  • Simplicity: A minimal API covering common levels and a withMinimumLevel filter.
  • Portability: Works in Node, Bun, Deno, and browsers.

Ready made facades

Install

npm:

npm i @apihive/logger-facade

yarn:

yarn add @apihive/logger-facade

Deno (via JSR):

import { LoggerFacade, ConsoleLogger } from "jsr:@apihive/logger-facade";

Quick start

import { ConsoleLogger } from "@apihive/logger-facade";

const logger = new ConsoleLogger().withMinimumLevel("info");

logger.debug("hidden"); // filtered out
logger.info("hello world");
logger.error("something went wrong", { code: 123 });

API

export type LogLevel = "none" | "trace" | "debug" | "info" | "warn" | "error" | "fatal";

export type LoggerFacade = {
  withMinimumLevel(level: LogLevel): LoggerFacade;
  trace(message: string, ...args: any[]): void;
  debug(message: string, ...args: any[]): void;
  info(message: string, ...args: any[]): void;
  warn(message: string, ...args: any[]): void;
  error(message: string, ...args: any[]): void;
  fatal(message: string, ...args: any[]): void;
};

Included implementation: ConsoleLogger

A no-dependency logger that writes to the browser/Node console and supports runtime level filtering via withMinimumLevel.

import { ConsoleLogger } from "@apihive/logger-facade";

const log = new ConsoleLogger().withMinimumLevel("warn");
log.info("hidden");
log.warn("visible");
log.error("visible");

Create your own adapter

You can wrap any logger to conform to LoggerFacade.

import MyLogger from "MyLogger";
import type { LoggerFacade, LogLevel } from "@apihive/logger-facade";

export function myLoggerFacade(base = new MyLogger()): LoggerFacade {
  return {
    withMinimumLevel(level: LogLevel) : LoggerFacade {
      return myLoggerFacade(base.spawn({ level }));
    },
    trace: (m, ...a) => base.trace(m, ...a),
    debug: (m, ...a) => base.debug(m, ...a),
    info:  (m, ...a) => base.info(m, ...a),
    warn:  (m, ...a) => base.warn(m, ...a),
    error: (m, ...a) => base.error(m, ...a),
    fatal: (m, ...a) => base.fatal(m, ...a),
  };
}

Usage in libraries

Libraries should accept a LoggerFacade (optionally with a default ConsoleLogger) and use it internally, e.g.:

import type { LoggerFacade } from "@apihive/logger-facade";

export function makeThing(logger: LoggerFacade) {
  logger.debug("creating thing");
  // ...
}

Applications decide which implementation to pass:

import { ConsoleLogger } from "@apihive/logger-facade";
import { makeThing } from "my-lib";

makeThing(new ConsoleLogger().withMinimumLevel("info"));

Design goals

  • Minimal: Just the common levels + level threshold.
  • Extensible: Add your own wrappers for any logging backend.
  • Stable: Low churn surface; easy to depend on from libraries.

License

MIT © apihive