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

@ynode/ylog

v1.7.0

Published

Helper module for outputting colored info, warn, error, debug and trace/verbose log messages. Works with Fastify or standalone.

Readme

@ynode/ylog

Copyright (c) 2025 Michael Welter [email protected]

npm version license

Helper module for outputting colored info, warn, error, debug and trace/verbose log messages. Works with Fastify or standalone Node.js application.

Installation

npm install @ynode/ylog

Basic Usage

import ylog from "@ynode/ylog";
const log = ylog(import.meta);

log.info(`[${process.pid}] Hello`);
log.warn(`[${process.pid}] Hello`);
log.error(`[${process.pid}] Hello`);

The optional level sets a logger-specific threshold, and pid includes the process ID in every line:

const log = ylog(import.meta, { level: "info", pid: true });
const fastify = Fastify({ loggerInstance: log });
fastify.log.info(`Worker ${process.pid} shutting down due to inactivity.`);

Log Levels

The supported levels, from most restrictive to most verbose, are silent, error, warn, info, debug, and verbose. The standard Pino/Fastify names fatal and trace are accepted as aliases for error and verbose, respectively.

const log = ylog(import.meta);

// Updates existing and future loggers that do not have an explicit level.
ylog.loglevel("warn");

// An explicit logger level remains independent of the global level.
const debugLog = ylog(import.meta, { level: "debug" });

ylog.defaultLevel exposes the current numeric global threshold, while ylog.levels contains the numeric value for each named level.

| Method | Threshold | Destination | Duplicate throttle | | ----------------------- | --------- | ----------- | ------------------ | | fatal() | error | stderr | No | | error() | error | stderr | Yes | | warn() | warn | stderr | Yes | | info() | info | stdout | No | | debug() | debug | stdout | No | | verbose() / trace() | verbose | stdout | No |

The silent() no-op method is provided for Fastify/Pino logger compatibility.

Child Loggers

child(bindings, options) composes contextual bindings and honors Fastify/Pino child options such as a route-specific level.

const requestLog = log.child({ reqId: "abc123" }, { level: "error" });
requestLog.error("Request failed");

Structured Output and Request Context

Set format: "json" to emit one JSON object per log call. Static logger bindings and active async context bindings are added as top-level fields, with core fields such as time, level, tag, msg, and enabled pid output protected from being overwritten.

const log = ylog(import.meta, {
    format: "json",
    bindings: { service: "api" },
});

await ylog.withContext({ reqId: "abc123" }, async () => {
    log.info("Request started");
});

Use ylog.getContext() to read the current context bindings inside the active async execution path.

Duplicate Throttling

Duplicate error and warn messages are limited to two emissions per 30-second window. Budgets are isolated by root logger and severity; derived child loggers share their parent's budget. Messages filtered by the active log level do not consume a budget, and fatal messages are never throttled.

Output Formatting

TTY output includes a local timestamp and uses colors when the destination stream supports them. Non-TTY output uses syslog severity prefixes suitable for journald. Stdout and stderr capabilities are detected independently, so redirecting one stream does not affect the other's formatting.

Call ylog.disableSyslogPrefix() before logging when a non-TTY destination should receive plain output instead. The setting is process-wide and affects existing and future loggers.

License

MIT