hb-smart-logger
v1.0.6
Published
Production-ready Winston logger with daily rotation, safe JSON handling, and logger.log() alias
Downloads
647
Maintainers
Readme
HB Smart Logger 🚀
HB Smart Logger is a production-ready logging solution for Node.js built on top of Winston, designed to be simple to use, safe by default, and scalable for real-world applications.
It works out of the box with zero configuration, yet provides advanced features like daily log rotation, safe JSON logging, and structured multi-argument logging.
✨ Key Benefits
✅ Zero-Config Setup
Just install and start logging — no boilerplate required.✅ Safe Object Logging
Handles circular JSON safely (no crashes, no[object Object]).✅ Daily Log Rotation
Automatically rotates logs by day and size, with compression and retention.✅ Separate & Combined Logs
Keeps per-level logs (error,warn,info,debug) and a full combined log.✅ Multi-Argument Support
Log multiple values likeconsole.log()— strings, objects, and errors.✅
logger.log()Alias
Drop-in replacement forconsole.log()— routes toinfolevel internally.✅ Error Stack Traces Included
Errors automatically log full stack traces.✅ Production-Ready Defaults
Designed for APIs, microservices, background workers, and cron jobs.
📦 Installation
npm install hb-smart-logger🚀 Quick Start
const logger = require("hb-smart-logger");
logger.log("Application started");
logger.info("Server listening", { port: 3000 });
logger.warn("Slow response", { endpoint: "/users", timeMs: 1420 });
logger.error("Database connection failed", new Error("ECONNREFUSED"));🧠 Smart Logging Examples
Log multiple arguments (like console.log)
logger.log("User login", userId, { role: "admin" });Log objects safely (no crashes)
const obj = {};
obj.self = obj;
logger.info("Circular object test", obj);Log errors with stack trace
try {
throw new Error("Something went wrong");
} catch (err) {
logger.error("Unhandled error", err);
}📁 Log Output Structure
HB Smart Logger automatically creates this structure:
logs/
combined/
combined-2026-01-05.log
error/
error-2026-01-05.log
warn/
warn-2026-01-05.log
info/
info-2026-01-05.log
debug/
debug-2026-01-05.log📂 What Goes Where?
log() / info()
logs/info/ + logs/combined/
warn()
logs/warn/ + logs/combined/
error()
logs/error/ + logs/combined/
debug()
logs/debug/ + logs/combined/🔄 Log Rotation (Built-In)
📅 Daily rotation
📦 Max size: 10 MB per file
🗜️ Compressed archives
🧹 Auto-cleanup: keeps last 30 days
No extra setup required.
🧪 Environment Friendly
Works in development, staging, and production
Colorized console output for local development
File-based logging for production systems
🛠️ Use Cases
✔ REST APIs
✔ Express / Fastify servers
✔ Background workers
✔ Cron jobs
✔ Microservices
✔ Long-running Node.js services
🔥 Why HB Smart Logger?
| Feature | console.log | winston | HB Smart Logger |
|--------|---------------|-----------|---------------------|
| Daily log rotation | ❌ | ❌ | ✅ |
| Circular JSON safe | ❌ | ❌ | ✅ |
| Per-level log files | ❌ | ⚠️ | ✅ |
| Combined log file | ❌ | ⚠️ | ✅ |
| logger.log() alias | ❌ | ❌ | ✅ |
| Multi-argument logging | ❌ | ❌ | ✅ |
| Ready-to-use defaults | ❌ | ⚠️ | ✅ |
📌 Requirements
Node.js >= 14
CommonJS environment
🧭 Roadmap
Planned enhancements:
Configurable log directory
JSON-only output mode
Express request/response middleware
TypeScript typings
Cloud logging support (AWS / GCP)
📄 License
MIT © 2026 Hafiz Bilal
