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

@kubex3/node-log

v1.3.2

Published

A high-performance TypeScript logging utility that automatically manages directory creation and generates structured .log files with both ANSI-colored console output and clean, plain-text file persistence.

Readme

📝 Node-Log

npm version License Build Status CI Status Socket Badge

A high-performance TypeScript logging utility for modern Node.js (ESM) applications. It automatically manages directory creation and generates structured .log files with both ANSI-colored console output and clean, plain-text file persistence.

✨ Features

  • Dual Output: Logs beautifully colored messages to the console while saving clean, uncolored text to your log files.
  • Auto-Directory Creation: Never worry about ENOENT errors. If your log folder doesn't exist, the utility creates it for you automatically.
  • Five Log Levels: Built-in support for INFO, WARNING, ERROR, AUDIT, EVENT and DEBUG.
  • Contextual Tagging: Easily attach a location or module name to your logs for lightning-fast debugging.
  • Zero-Config Ready: Works out of the box, or can be easily customized via .env variables.
  • Native ESM: Built specifically for modern "type": "module" Node.js environments.

📦 Installation

Install the package via npm:

npm i @kubex3/node-log

⚙️ Configuration

By default, file logging is enabled and logs are saved to ./logs/system.log. Note that debug logging and file output are environment-dependent for example, detailed debug traces are typically disabled when NODE_ENV="production" to ensure system stability.

Configuration Options

| Variable | Description | Default | | :--- | :--- | :--- | | LOG_ENABLED | Set to true to write logs to a file, or false to only show them in the console. | true | | LOG_FILE_PATH | The relative or absolute path where the log file should be created. | ./logs/system.log | | NODE_ENV | Set to production to optimize logging and suppress verbose debug output. | development |

Example .env Setup

# Enable or disable file logging (true/false)
LOG_ENABLED="true"

# Custom location for your log files
LOG_FILE_PATH="./src/storage/logs/application.log"

# Environment setting (affects log verbosity)
NODE_ENV="production"

🚀 Usage

Import the logging functions into your file. Since this is an ESM package, you can use modern import syntax.

import { 
  logInfo, 
  logWarning, 
  logError, 
  logAudit, 
  logEvent 
} from "node-log";

// 1. Basic Logging
logInfo("Server successfully started on port 3000");
logEvent("Daily database backup triggered");

// 2. Logging with Context/Location (Highly Recommended)
// Adding a second string argument tags the log with a specific module or file name.
logWarning("High memory usage detected", "SystemMonitor");
logError("Failed to connect to Redis cluster", "CacheService");
logAudit("User password updated successfully", "AuthModule");

💻 Console Output (With ANSI Colors)

[2026-03-27 - 14:30:15] [  INFO   ] - Server successfully started on port 3000
[2026-03-27 - 14:30:15] [  EVENT  ] - Daily database backup triggered
[2026-03-27 - 14:30:16] [ WARNING ]  - [SystemMonitor] - High memory usage detected
[2026-03-27 - 14:30:16] [  ERROR  ]    - [CacheService] - Failed to connect to Redis cluster
[2026-03-27 - 14:30:17] [  AUDIT  ]    - [AuthModule] - User password updated successfully

📄 File Output (system.log)

The exact same logs are safely appended to your .log file, stripped of ANSI color codes for clean parsing by tools like Datadog, Splunk, or ElasticSearch.

[2026-03-27 - 14:30:15] [  INFO   ] - Server successfully started on port 3000
[2026-03-27 - 14:30:15] [  EVENT  ] - Daily database backup triggered
[2026-03-27 - 14:30:16] [ WARNING ]  - [SystemMonitor] - High memory usage detected
[2026-03-27 - 14:30:16] [  ERROR  ]    - [CacheService] - Failed to connect to Redis cluster
[2026-03-27 - 14:30:17] [  AUDIT  ]    - [AuthModule] - User password updated successfully

🛠️ API Reference

All functions share the same signature: functionName(message: string, location?: string): void

| Function | Color | Best Used For | | :--- | :--- | :--- | | logInfo() | 🟢 Green | Standard system operations, startup messages, and expected behaviors. | | logWarning() | 🟡 Yellow | Non-critical issues, deprecations, or approaching limits (e.g., high RAM). | | logError() | 🔴 Red | Fatal exceptions, unhandled rejections, and system failures. | | logAudit() | 🔵 Cyan | Security events, login attempts, configuration changes, and authorization. | | logEvent() | 🟣 Magenta | Business logic milestones, cron job executions, and user-triggered workflows. | | logDebug() | ⚪ White | Verbose "behind-the-scenes" data, variable states, and deep troubleshooting. |


👨‍💻 Development

Want to contribute to the project?

  1. Clone the repository:

    git clone https://github.com/KubeX3/node-log.git
  2. Install dependencies:

    npm install
  3. Run the test suite:

    npm run test
  4. Build the project:

    npm run build

📜 License

Designed and developed by KubeX3.

Licensed under the Apache License 2.0.