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

@reasonable-stack/logger

v0.1.1

Published

A reasonably good logger.

Readme

@reasonable-stack/logger

A reasonably good logger.

Five methods, one per syslog severity from error down to debug, written to stdout / stderr as either colored text for terminals or one JSON object per line for log collectors. No transports, no child loggers, no dependencies.

Installation

npm install @reasonable-stack/logger

Quick start

import { createLogger } from '@reasonable-stack/logger';

const log = createLogger({ level: 'debug' });

log.debug('connecting to the database');
log.info('server listening on :3000');
log.warning('config file not found, using defaults');
log.error(new Error('connection refused'));
14:03:07.512 [DBG] connecting to the database
14:03:07.512 [INF] server listening on :3000
14:03:07.513 [WRN] config file not found, using defaults
14:03:07.513 [ERR] Error: connection refused

Levels

| method | name | severity | label | accepts | stream | | :-------- | :-------- | -------: | :---- | :---------------- | :------- | | error | ERROR | 3 | ERR | string \| Error | stderr | | warning | WARNING | 4 | WRN | string \| Error | stdout | | notice | NOTICE | 5 | NTC | string | stdout | | info | INFO | 6 | INF | string | stdout | | debug | DEBUG | 7 | DBG | string | stdout |

A logger writes entries at its level and every level more severe (lower number) than it. Methods for less severe levels are no-ops.

const log = createLogger({ level: 'warning' });

log.warning('disk 90% full'); // written
log.info('request handled');  // ignored

Options

| option | type | default | description | | :------- | :---------- | :---------- | :--------------------------------- | | level | Level | 'info' | least severe level written | | json | boolean | false | one JSON object per line | | format | Formatter | undefined | custom formatter, wins over json | | silent | boolean | false | only write errors, ignores level |

Level is one of 'error', 'warning', 'notice', 'info' or 'debug', always in lowercase.

Output formats

The default, pretty, is meant for a human reading a terminal: the time of day in UTC (dimmed) followed by the level label (colored by severity) and the message.

17:57:26.351 [INF] server started

With json: true, each entry is a single line of JSON, with the timestamp as a full ISO 8601 string in UTC:

const log = createLogger({ json: true });

log.error(new RangeError('page must be positive'));
// => {"level":"ERROR","message":"RangeError: page must be positive","timestamp":"2026-11-26T17:57:26.351Z"}

Custom formatters

A Formatter is a function from a LogEntry to a string. The logger trims whatever it returns and adds a single trailing newline.

| field | type | description | | :---------- | :---------------- | :---------------------------------- | | level | object | { code, name, abv, stream } | | message | string \| Error | exactly what was passed to a method | | timestamp | Date | when the method was called |

Both built-in formatters are exported as formatters.pretty and formatters.json, so a custom one can build on them:

import { createLogger, formatters, type Formatter } from '@reasonable-stack/logger';

const withPid: Formatter = (entry) => `[${process.pid}] ${formatters.pretty(entry)}`;

const log = createLogger({ format: withPid });

log.info('worker ready'); // => [4242] 17:57:26.351 [INF] worker ready

Things worth knowing

  • silent still writes errors. It raises the threshold to 'error', it doesn't turn the logger off.
  • Errors lose their stack. Both built-in formatters render an Error as `${name}: ${message}`; the stack trace and cause are dropped. Write a custom formatter if you need them.
  • Colors are always on. The pretty formatter emits ANSI escape codes even when the output isn't a terminal, and it doesn't honor NO_COLOR. Prefer json: true when logs go to a file or a collector.
  • Pretty timestamps are UTC time only, with no date and no offset.
  • Node.js or Bun only. Entries are written with process.stdout and process.stderr, so it won't run in a browser.

License

MIT