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

@haensl/iso-log

v3.1.2

Published

Isomorphic logger with Bunyan and Sentry support.

Readme

@haensl/iso-log

A tiny isomorphic logging facade for JavaScript applications.

NPM npm version CircleCI

@haensl/iso-log provides a single logging API that works in browsers, Node.js, and frameworks such as Next.js without introducing runtime dependencies on server-only modules.

The logger starts in a buffering mode and can be initialized later once the host application knows which logger and error reporting implementation it wants to use.

Features

  • Isomorphic (Browser + Node.js)
  • No hard dependency on Bunyan, Sentry, or any other logging backend
  • Buffers log messages before initialization
  • Optional error reporting integration
  • Tiny API surface
  • ESM-first

Installation

npm install @haensl/iso-log

Quick Start

import log from '@haensl/iso-log';

log.info('Application starting...');

log.init();

log.info('Application started.');

Initialization

The logger can be initialized with:

  • a custom logger implementation
  • an error reporting callback
import log from '@haensl/iso-log';

log.init({
  logger: console,
  onError: (error) => {
    console.error('Reporting error:', error);
  }
});

Configuration

| Option | Type | Required | Description | |----------|----------|----------|----------| | logger | Object | No | Logger implementation to use | | onError | Function | No | Called for every Error passed to warn() or error() |

Logger Interface

A custom logger should implement any subset of:

{
  debug(...args) {},
  info(...args) {},
  warn(...args) {},
  error(...args) {}
}

Methods are optional.

Example:

log.init({
  logger: {
    info: (...args) => console.log('[INFO]', ...args),
    error: (...args) => console.error('[ERROR]', ...args)
  }
});

Error Reporting

Errors passed to warn() and error() can be forwarded to an external service.

log.init({
  onError: (error) => {
    sentry.captureException(error);
  }
});

Example:

log.error(new Error('Something exploded'));

The supplied callback receives:

Error

instances only.

Non-error arguments are ignored.

log.error(
  'Something exploded',
  new Error('Boom')
);

Only the Error object is reported.

Buffering

Calls made before initialization are buffered.

log.info('A');
log.info('B');
log.info('C');

log.init({
  logger: console
});

The buffered messages are flushed in FIFO order:

A
B
C

This makes it safe to log during application startup before logging infrastructure has been configured.

API

log.init(options?)

Initialize the logger.

log.init({
  logger,
  onError
});

log.debug(...args)

Write a debug message.

log.debug('Loading user', userId);

log.info(...args)

Write an informational message.

log.info('Server started');

log.warn(...args)

Write a warning.

Errors are forwarded to onError.

log.warn(
  'Unexpected response',
  new Error('Invalid payload')
);

log.error(...args)

Write an error.

Errors are forwarded to onError.

log.error(
  'Request failed',
  new Error('Connection refused')
);

Bunyan Example

import bunyan from 'bunyan';
import log from '@haensl/iso-log';

log.init({
  logger: bunyan.createLogger({
    name: 'api'
  })
});

Sentry Example

import * as Sentry from '@sentry/node';
import log from '@haensl/iso-log';

Sentry.init({
  dsn: process.env.SENTRY_DSN
});

log.init({
  logger: console,
  onError: Sentry.captureException
});

Next.js Example

Client:

import * as Sentry from '@sentry/nextjs';
import log from '@haensl/iso-log';

log.init({
  onError: Sentry.captureException
});

Server:

import bunyan from 'bunyan';
import * as Sentry from '@sentry/nextjs';
import log from '@haensl/iso-log';

log.init({
  logger: bunyan.createLogger({
    name: 'web'
  }),
  onError: Sentry.captureException
});

Changelog

License