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

@dynamic-mock-server/logger

v0.1.0-beta

Published

Logger for Dynamic Mock Server — Pino-based structured logging with namespace support

Readme

@dynamic-mock-server/logger

Pino-based logger with pretty formatting and namespacing

Lightweight logger wrapper around Pino with pino-pretty for beautiful terminal output. Provides namespacing for organized logging across different modules.

Features

  • 📝 Pino-Based: Built on high-performance Pino logger
  • 🎨 Pretty Output: Colorized, readable logs with pino-pretty
  • 🏷️ Namespacing: Create child loggers with namespace bindings
  • 🎯 Log Levels: Full support for trace, debug, info, warn, error, fatal
  • ⚙️ Configurable: Custom log levels and options
  • 🚀 Fast: Zero-cost abstractions over Pino

Installation

pnpm add @dynamic-mock-server/logger

Quick Start

Basic Usage

import { Logger } from "@dynamic-mock-server/logger";

// Create logger with default settings
const logger = new Logger();

logger.info("Server started");
logger.debug("Loading configuration");
logger.warn("Deprecation warning");
logger.error("Failed to load file");

With Log Level

import { Logger } from "@dynamic-mock-server/logger";

const logger = new Logger({ level: "debug" });

logger.trace("Very detailed"); // Won't show (below debug)
logger.debug("Debugging info"); // Shows
logger.info("Information"); // Shows

Namespaced Loggers

import { Logger } from "@dynamic-mock-server/logger";

const logger = new Logger();

// Create namespaced loggers
const routesLogger = logger.namespace("routes");
const pluginsLogger = logger.namespace("plugins");

routesLogger.info("Route registered");
// Output: [routes] Route registered

pluginsLogger.info("Plugin loaded");
// Output: [plugins] Plugin loaded

Child Loggers with Bindings

import { Logger } from "@dynamic-mock-server/logger";

const logger = new Logger();

// Create child with custom bindings
const requestLogger = logger.child({ requestId: "abc123", userId: "user1" });

requestLogger.info("Processing request");
// Output includes: requestId: "abc123", userId: "user1"

API Reference

Logger Class

Constructor

constructor(options?: LoggerOptions)

LoggerOptions:

  • level?: string - Log level (trace, debug, info, warn, error, fatal). Default: "info"
  • options?: pino.LoggerOptions - Additional Pino options

Log Methods

trace(...args: Parameters<LogFn>)
debug(...args: Parameters<LogFn>)
info(...args: Parameters<LogFn>)
warn(...args: Parameters<LogFn>)
error(...args: Parameters<LogFn>)
fatal(...args: Parameters<LogFn>)

Log at different levels.

logger.info("Simple message");
logger.info({ userId: 123 }, "User logged in");
logger.error({ err: error }, "Failed to process");

Utility Methods

child(bindings?: Record<string, unknown>): Logger

Create a child logger with additional bindings.

const childLogger = logger.child({ module: "auth" });
childLogger.info("Authentication successful");
namespace(name: string): Logger

Create a namespaced logger (shorthand for child({ namespace: name })).

const apiLogger = logger.namespace("api");
apiLogger.info("API request received");
get raw(): pino.Logger

Access the underlying Pino logger instance.

const pinoLogger = logger.raw;

Log Levels

Available log levels (in order of severity):

  1. trace - Very detailed debugging
  2. debug - Detailed debugging
  3. info - General information (default)
  4. warn - Warnings
  5. error - Errors
  6. fatal - Fatal errors

Set via environment variable:

LOG_LEVEL=debug npm start

Or via constructor:

const logger = new Logger({ level: "debug" });

Examples

Complete Server Logging

import { Logger } from "@dynamic-mock-server/logger";

const logger = new Logger({ level: process.env.LOG_LEVEL || "info" });

// Module-specific loggers
const serverLogger = logger.namespace("server");
const routesLogger = logger.namespace("routes");
const dbLogger = logger.namespace("database");

serverLogger.info("Starting server on port 3000");
routesLogger.info("Loaded 15 routes");
dbLogger.warn("Connection pool nearing capacity");

Request Logging

import { Logger } from "@dynamic-mock-server/logger";

const logger = new Logger();

function handleRequest(req: Request) {
  const requestLogger = logger.child({
    requestId: req.id,
    method: req.method,
    url: req.url,
  });

  requestLogger.info("Request started");

  try {
    // Process request
    requestLogger.info("Request completed");
  } catch (error) {
    requestLogger.error({ err: error }, "Request failed");
  }
}

Dependencies

  • pino - High-performance logger
  • pino-pretty - Pretty formatting for development

Related Packages

License

Apache-2.0 © Miguel Martínez