logsave-hub
v1.0.0
Published
Ethical dual-mode Automatic log rotation and persistent logging for Node.js (ESM + CJS)
Maintainers
Readme
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 / erroroverride - ✍️ 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:
- Console override mode (automatic)
- 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.logExample 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 usinglog.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.
