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

@squaredmade/logger

v1.1.2

Published

A flexible and customizable logging utility built on top of Winston for Node.js applications.

Downloads

10

Readme

@squaredmade/logger

A flexible and customizable logging utility built on top of Winston for Node.js applications.

Features

  • Supports all Winston log levels (error, warn, info, http, verbose, debug)
  • Allows for custom prefixes and service names
  • File logging for errors and combined logs
  • Console output in non-production environments
  • Customizable log formats
  • String interpolation support using Node.js util.format

Usage

Basic Usage

import createCustomLogger from "@squaredmade/logger";

// Create a logger with default options
const logger = createCustomLogger("example");

// Use the logger
logger.info("This is an info message");
logger.error("An error occurred", { errorCode: 500 });

String Interpolation

To support string interpolation in log messages, use Node.js's built-in util.format. You can include placeholders (%s, %d, etc.) in your log messages and pass additional arguments, just like with console.log:

import util from "util";
import createCustomLogger from "@squaredmade/logger";

const logger = createCustomLogger();

const userId = 123;
logger.info(util.format("User %d logged in", userId));
// Output: 2023-05-01T12:34:56.789Z INFO: User 123 logged in

Log Levels

Each log level represents the severity or type of event being logged. The logger will only output messages at the current log level and those with a higher severity (lower numerical value). For example, if the log level is set to info, it will include info, warn, and error messages, but not debug or verbose messages.

  1. error (Level 0):

    • Purpose: Logs critical failures or errors that prevent a system or application from functioning properly.

    • Use Cases: When a request fails, an uncaught exception occurs, or a critical issue impacts the system's ability to operate.

    • Example:

      logger.error("Database connection failed", { errorCode: 500 });
  2. warn (Level 1):

    • Purpose: Logs potential issues that could become problems in the future but don't stop the system from functioning.

    • Use Cases: When something unexpected happens, or when the application is functioning but at risk.

    • Example:

      logger.warn("Memory usage is nearing the limit", {
        memoryUsage: "90%",
      });
  3. info (Level 2):

    • Purpose: Logs general information about the application's operation, such as state changes or major events.

    • Use Cases: Informational messages about application events, such as successful requests, system startups, or configurations.

    • Example:

      logger.info("User logged in", { userId: 123 });
  4. http (Level 3):

    • Purpose: Logs HTTP requests and responses, often used to track API traffic or web server interactions.

    • Use Cases: Logging incoming requests, response times, or status codes for monitoring web server activity.

    • Example:

      logger.http("GET /api/users - 200 OK", { duration: "200ms" });
  5. verbose (Level 4):

    • Purpose: Logs detailed messages for tracing the flow through the application, providing insight into application behavior.

    • Use Cases: Useful during development or debugging when you need more detailed information about the app's inner workings.

    • Example:

      logger.verbose("Processing user login", { userId: 123 });
  6. debug (Level 5):

    • Purpose: Logs information helpful for debugging, such as detailed state changes, variable values, or function calls.

    • Use Cases: Typically used for debugging the codebase to help pinpoint issues during development or while diagnosing production problems.

    • Example:

      logger.debug("Variable x has value", { x: 42 });

How to Use Log Levels

You can set the log level by configuring the LOG_LEVEL environment variable. If it is not set, it defaults to info, which means info, warn, and error messages will be logged, but not debug or verbose.

  • Production: Commonly set to warn or error to reduce noise and focus on issues.
  • Development: Often set to debug or verbose for detailed logging of application behavior.

By adjusting the log level, you can control how much information is logged and prevent excessive or irrelevant logging in certain environments (e.g., production vs. development).

File Logging

By default, the logger writes logs to two files:

  • error.log: Contains only error-level logs
  • combined.log: Contains all logs

These files are created in the root directory of the project.

Console Output

In non-production environments (NODE_ENV !== "production"), logs are also output to the console with color-coding for better readability.

Customization

If you need further customization, you can modify the src/index.ts file in this package. Remember to rebuild the package after making changes:

pnpm build