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 🙏

© 2025 – Pkg Stats / Ryan Hefner

traillog

v1.0.2

Published

A lightweight and colorful logging utility for Node.js with timestamps, metadata, and file tracking.

Readme

Traillog

Traillog is a simple, colorful logging utility for Node.js applications. It provides an easy way to add formatted, color-coded logs with timestamps and caller information for better debugging and log readability.

Features

  • Color-coded log messages using chalk
  • Timestamp for each log entry
  • Caller's file and line number for easy tracing
  • Support for different log levels: SUCCESS, ERROR, WARN, and INFO
  • Optional metadata logging in JSON format

Installation

To install Traillog, run the following command in your project directory:

npm install traillog

Usage

First, import the logger from traillog in your JavaScript or TypeScript file:

import logger from "traillog";

Then, you can use the different logging methods:

// Log a success message
logger.success("Operation completed successfully");

// Log an error message
logger.error("An error occurred", { errorCode: 500 });

// Log a warning message
logger.warn("This is a warning");

// Log an informational message
logger.info("This is an informational message", { user: "John Doe" });

Each logging method accepts two parameters:

  1. message (required): The main log message as a string.
  2. meta (optional): An object containing additional metadata to be logged.

Output

The log output will be formatted as follows:

[TIMESTAMP] [LOG_LEVEL] (FILE:LINE): MESSAGE
METADATA (if provided)

For example:

[2023-05-20T12:34:56.789Z] [SUCCESS] (src/app.ts:42): Operation completed successfully
[2023-05-20T12:34:57.123Z] [ERROR] (src/app.ts:45): An error occurred
{
  "errorCode": 500
}

API Reference

The logger object exposes four main methods for logging:

logger.success(message, meta?)

Logs a success message in green.

  • message (string): The success message to log.
  • meta (object, optional): Additional metadata to log.

Example:

logger.success("Data saved successfully", { id: 123 });

logger.error(message, meta?)

Logs an error message in red.

  • message (string): The error message to log.
  • meta (object, optional): Additional metadata to log, such as error details.

Example:

logger.error("Failed to connect to database", { errorCode: "DB_001" });

traillog.warn(message, meta?)

Logs a warning message in yellow.

  • message (string): The warning message to log.
  • meta (object, optional): Additional metadata to log.

Example:

logger.warn("Deprecated function called", { function: "oldMethod" });

traillog.info(message, meta?)

Logs an informational message in blue.

  • message (string): The informational message to log.
  • meta (object, optional): Additional metadata to log.

Example:

logger.info("User logged in", { userId: "user123", timestamp: Date.now() });

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.