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

ink-logs

v1.0.0

Published

A small TypeScript logging utility that prints formatted, color-coded messages to the terminal using [`chalk`](https://www.npmjs.com/package/chalk).

Readme

Terminal Logger

A small TypeScript logging utility that prints formatted, color-coded messages to the terminal using chalk.

Features

  • Success, error, warning, and info log levels
  • Bright, bold colors for each log level
  • Consistent 80-character output width
  • Automatic wrapping for long messages
  • Default messages for each log function

Requirements

  • Node.js
  • TypeScript
  • chalk
  • ts-node-dev (for the example development script)

Installation

Install the required packages in your project:

npm install chalk
npm install --save-dev typescript ts-node-dev

If you use ts-node-dev to run the project during development, add a script like this to your package.json:

{
  "scripts": {
    "dev": "ts-node-dev --respawn --transpile-only src/index.ts"
  }
}

Make sure your project is configured for TypeScript and that your chalk version is compatible with your Node.js module setup. The code uses ES module-style imports.

Usage

Save the logger code in a file such as src/logger.ts, then import the functions wherever you need them:

import {
  successLog,
  errorLog,
  warningLog,
  infoLog,
} from "./logger";

successLog("Configuration loaded");
errorLog("Unable to connect to the database");
warningLog("This setting is deprecated");
infoLog("Server is starting");

Each function accepts an optional message. If no message is provided, it uses its default text:

successLog(); // Operation Completed Successfully
errorLog();   // Something went wrong during execution
warningLog(); // Potential issue identified
infoLog();    // Just a heads up

Example output

The output is displayed in the terminal with a colored border and a label for the log level. Exact colors depend on terminal and chalk support.

--------------------------------------------------------------------------------
SUCCESS - Configuration loaded
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
ERROR - Unable to connect to the database
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
WARNING - This setting is deprecated
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
INFO - Server is starting
--------------------------------------------------------------------------------

API

| Function | Default message | Description | | --- | --- | --- | | successLog(msg?) | Operation Completed Successfully | Logs a success message in bright green and bold. | | errorLog(msg?) | Something went wrong during execution | Logs an error message in bright red and bold. | | warningLog(msg?) | Potential issue identified | Logs a warning message in bright yellow and bold. | | infoLog(msg?) | Just a heads up | Logs an informational message in bright cyan and bold. |

How it works

  • handler() selects the color and formats the message for the chosen log level.
  • wrapText() wraps the message to fit the configured width.
  • Each log call prints a top border, the message lines, and a bottom border.

Configuration

The output width is controlled by MAX_WIDTH in the source:

const MAX_WIDTH = 80;

Change this value to adjust the intended line width.

Notes

  • The width calculation uses JavaScript string length, so it does not account for terminal display width of all Unicode characters or ANSI escape sequences.
  • If a single word is longer than the available line width, the current wrapping logic does not split that word.
  • For reliable wrapping, ensure the wrapText() implementation includes a space when calculating the next line's length. The provided code can also be improved to avoid emitting an empty first line when a word is too long.
  • The development script shown above assumes your entry point is src/index.ts.

License

Add your preferred license here (for example, MIT) before publishing.