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

@soorria/logger

v2.0.0

Published

Opinionated structured JSON logging

Readme

@soorria/logger

Opinionated structured logging for Node.js with optional async context support.

xkcd: Standards

Features

  • Structured JSON logging - Machine-readable logs for production
  • Pretty formatting - Human-readable colored output for development
  • Async context tracking - Automatically attach request IDs, job IDs, etc. to all logs within a context
  • Child loggers - Create scoped loggers with additional metadata

Installation

pnpm add @soorria/logger

Quick Start

import { Logger } from "@soorria/logger";
import { getDefaultConfig } from "@soorria/logger/default-config";

const logger = new Logger({
  ...getDefaultConfig({ production: process.env.NODE_ENV === "production" }),
});

logger.info("Hello world");
logger.error("Something went wrong", { userId: 123 });

Formatters

JSON Formatter

Outputs structured JSON, ideal for production environments and log aggregation services.

import { JsonLogFormatter } from "@soorria/logger/json";

// Compact output (single line per log)
const formatter = new JsonLogFormatter({ compact: true });

// Pretty JSON (multi-line, for debugging)
const formatter = new JsonLogFormatter({ compact: false });

Pretty Formatter

Colorful, human-readable output for local development.

import { PrettyLogFormatter } from "@soorria/logger/pretty";

const formatter = new PrettyLogFormatter({ colors: true });

Default Configuration

Use the built-in helper to get sensible defaults based on environment:

import { Logger } from "@soorria/logger";
import { getDefaultConfig } from "@soorria/logger/default-config";

const logger = new Logger({
  ...getDefaultConfig({ production: process.env.NODE_ENV === "production" }),
});

This uses:

  • Production: Compact JSON formatter
  • Development: Pretty colored formatter

Async Context

Automatically attach contextual information (like request IDs) to all logs within an async scope:

import { Logger } from "@soorria/logger";
import { getLogContext, runWithContext } from "@soorria/logger/async-context";
import { getDefaultConfig } from "@soorria/logger/default-config";

const logger = new Logger({
  ...getDefaultConfig({ production: false }),
  getLogContext,
});

// In your request handler
runWithContext({ requestId: "abc-123" }, () => {
  logger.info("Processing request"); // Includes requestId in output
  doSomething();
});

function doSomething() {
  // Context is automatically available
  logger.info("Doing something"); // Also includes requestId
}

Mutating Context

Add additional context within a scope:

import { mutateContextScope } from "@soorria/logger/async-context";

runWithContext({ requestId: "abc-123" }, () => {
  // Later in the request...
  mutateContextScope({ userId: "user-456" });

  logger.info("User action"); // Includes both requestId and userId
});

Child Loggers

Create loggers with additional scope attached to every log:

const logger = new Logger({
  /* config */
});

const userLogger = logger.child({ module: "users" });
userLogger.info("User created"); // Includes module: "users"

const specificLogger = userLogger.child({ userId: 123 });
specificLogger.info("Password changed"); // Includes module and userId

Log Levels

Available log levels (in order of severity):

logger.debug("Detailed debugging info");
logger.info("General information");
logger.warn("Warning messages");
logger.error("Error messages");
logger.fatal("Critical errors");
logger.silent(); // No output

Configure minimum log level:

import { Logger, LogLevel } from "@soorria/logger";

const logger = new Logger({
  logLevel: LogLevel.warn, // Only warn, error, fatal will be logged
  // or
  logLevel: "warn", // String version also works
  // ...
  logLevel: process.env.LOG_LEVEL,
});

Error Handling

Errors are automatically serialized with stack traces and causes:

try {
  throw new Error("Something broke", { cause: new Error("Root cause") });
} catch (error) {
  logger.error("Operation failed", error);
}

Exports

| Export | Description | | -------------------------------- | ------------------------------------------------------- | | @soorria/logger | Core Logger class and types | | @soorria/logger/json | JsonLogFormatter | | @soorria/logger/pretty | PrettyLogFormatter | | @soorria/logger/console | ConsoleTransport | | @soorria/logger/async-context | runWithContext, getLogContext, mutateContextScope | | @soorria/logger/default-config | getDefaultConfig helper |

License

MIT