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

logsave-hub

v1.0.0

Published

Ethical dual-mode Automatic log rotation and persistent logging for Node.js (ESM + CJS)

Readme

npm version npm downloads license

logsave-hub 🚀

logsave-hub is an ethical, easy-to-use logging utility for Node.js that supports
both automatic console logging and explicit log APIs, with full ESM + CommonJS compatibility.

It is designed to be:

  • ✅ Beginner-friendly
  • ✅ Explicit & ethical (no hidden side effects)
  • ✅ Works in both ESM and CJS
  • ✅ Production-ready
  • ✅ Built with TypeScript

✨ Features

  • 📁 Automatically creates a logs/ directory
  • 🕒 Timestamped daily log files
  • 🖥 Optional console.log / warn / error override
  • ✍️ Explicit logging API (log.save, log.warn, log.error)
  • 🔄 Works in ESM and CommonJS
  • 🔒 No cloud upload, no data sharing — local only

📦 Installation

Install using npm:

npm install logsave-hub

🚀 Basic Usage

Do all this in the entry point of the file (index.js/server.js)

logsave-hub exposes two modes:

  1. Console override mode (automatic)
  2. Explicit logging mode (log.save())

You must explicitly initialize logging using enableLogging().


1️⃣ Console Override Mode (Automatic Logging)

In this mode, all console.log, console.warn, and console.error are automatically written to log files.

▶️ ESM Example

import enableLogging from "logsave-hub";

enableLogging({
  override: true,
  outDir: "./logs"
});

console.log("Server started");
console.warn("Low memory");
console.error("Something went wrong");

▶️ CommonJS Example

const enableLogging = require("logsave-hub").default;

enableLogging({
  override: true,
  outDir: "./logs"
});

console.log("Server started");
console.warn("Low memory");
console.error("Something went wrong");

2️⃣ Explicit Logging Mode (log.save())

In this mode, the console is not overridden. You explicitly control what gets logged.

▶️ ESM Example

import enableLogging, { log } from "logsave-hub";

enableLogging({
  override: false,
  outDir: "./logs"
});

log.save("Application started");
log.warn("Cache is almost full");
log.error("Database connection failed");

▶️ CommonJS Example

const enableLogging = require("logsave-hub").default;
const { log } = require("logsave-hub");

enableLogging({
  override: false,
  outDir: "./logs"
});

log.save("Application started");
log.warn("Cache is almost full");
log.error("Database connection failed");

🗂 Log Output

Logs are written to the specified directory (default: ./logs):

logs/
└─ app-2025-12-19.log

Example log content:

2025-12-19 17:16:21 [INFO] Server started
2025-12-19 17:16:31 [WARN] Cache is almost full
2025-12-19 17:16:41 [ERROR] Database connection failed

⚙️ Configuration Options

enableLogging({
  override?: boolean; // default: true
  outDir?: string;   // default: "./logs"
});

| Option | Description | |--------|------------| | override | Whether to override console.log | | outDir | Directory where logs are stored |


❗ Important Notes

  • enableLogging() must be called before using log.save()
  • Calling enableLogging() multiple times is safe
  • Logs are stored locally only
  • No network, no cloud, no tracking

🧠 Why logsave-hub?

Many loggers either:

  • Are too complex ❌
  • Don’t support both ESM & CJS ❌

logsave-hub is designed to be:

  • Explicit
  • Predictable
  • Easy to integrate
  • Safe for beginners and professionals

🧪 Supported Environments

  • Node.js 18+
  • Node.js 20+
  • Node.js 22+
  • Node.js 24+

📜 License

MIT © Koda Adam


❤️ Contributing

Pull requests and suggestions are welcome.
This package is built for the community.