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

ground-log

v1.0.0

Published

A advanced logger

Readme

Ground Log

GNU License

A zero-dependency, fully configurable logger for Node.js and the browser.
Supports structured logging, correlation IDs, level control, pretty printing, error stack formatting, custom colors, and more.


Try it Online

Test ground-log directly in your browser using StackBlitz:

Open in StackBlitz


Installation

Install via npm:

npm install ground-log

Features

  • Zero dependency core
  • Enable/disable log levels individually (warning, error, success)
  • Correlation ID / request tracing per log or global
  • JSON structured logging
  • Pretty print objects and arrays
  • Automatic error stack formatting
  • Custom color system (built-in ANSI, no chalk)
  • Prefix support for logs
  • Level-based log enabling/disabling via config
  • Safe handling for untrusted input
  • Support for nested objects with indentation
  • Optional function to sanitize log input
  • ANSI escape stripping for security
  • Timestamp included by default
  • Optional global log context (e.g., user, request info)
  • Optional function overrides for custom log formatting

Usage

Create a logger

import { createLogger } from "ground-log";

const logger = createLogger({
  logPrefix: true,
  logColor: true,
  logAsJson: false,
  prettyPrint: true,
  correlationId: "req-123",
  levels: { warning: true, error: true, success: true },
  sanitizeInput: true, // default
});

Basic logging

logger.logWarning("This is a warning");
logger.logError("Something failed");
logger.logSuccess("Operation completed");

Disable specific log levels

const logger = createLogger({
  levels: {
    success: false,
  },
});

logger.logSuccess("This will NOT appear");
logger.logError("This will appear");

JSON logging (for structured logs)

const logger = createLogger({
  logAsJson: true,
  prettyPrint: true,
});

logger.logError("Database connection failed");
logger.logWarning({ user: "constt", action: "login" });

Output:

{
  "type": "error",
  "message": "Database connection failed",
  "timestamp": 1712470000000,
  "correlationId": "req-123"
}

Logging objects

logger.logWarning({
  user: "constt",
  action: "login",
  ip: "127.0.0.1",
});

Logging errors (with stack)

logger.logError(new Error("Something broke"));

Automatically includes stack trace.


Per-request correlation ID

logger.logWarning("User login", "req-999");
logger.logError("Database failed", "req-999");

Pretty printing nested objects

logger.logWarning({
  user: "constt",
  actions: ["login", "update_profile", "logout"],
  meta: { ip: "127.0.0.1", browser: "firefox" },
});

Configuration Options

| Option | Type | Default | Description | | ------------- | -------------------------- | --------- | -------------------------------------------------------------------- | | logPrefix | boolean | true | Add prefix for logs | | logColor | boolean | true | Enable colored output | | logAsJson | boolean | false | Output logs as JSON | | prettyPrint | boolean | false | Pretty-print objects/JSON | | correlationId | string | undefined | Global correlation/request ID | | levels | object (LogType → boolean) | all true | Enable/disable individual log levels (warning, error, success) | | sanitizeInput | boolean | true | Remove ANSI sequences and unsafe characters from input |


Security Notes

Log Injection

User-controlled input may manipulate logs:

logger.logWarning("\n[ERROR] fake log");

Mitigation:

  • Use JSON mode in production
  • Sanitize user input

ANSI Escape Injection

Attackers can inject terminal codes:

"\x1b[31mHACKED";

Mitigation:

  • Strip ANSI sequences for untrusted input

Sensitive Data Exposure

Avoid logging:

  • Passwords
  • Tokens
  • Personal identifiable information

Authors


Support


Feedback

Post feedback or suggestions on Discord.


License

This project is licensed under the GNU GPLv3 License.


Takeaways

  • Core is zero dependency → secure, lightweight, and fast
  • Supports structured JSON logging and correlation IDs
  • Configurable per log level, prefix, color, and output format
  • Designed for both dev (pretty, color) and production (JSON, structured) environments
  • Safe defaults with optional overrides for custom formatting
  • sanitizeInput is on by default to prevent malicious input