live-logger-node
v1.0.2
Published
Realtime live logger middleware for Node.js and Express with SSE streaming
Downloads
63
Maintainers
Readme
🚀 live-logger-node
Realtime live logger middleware for Express and Node.js.
Stream logs live in browser using SSE.
✨ Features
- Live logs endpoint
- Console log capture
- Request logging
- Error logging
- Uncaught exception logging
- Unhandled rejection logging
- Auto log trimming
- Winston powered
- TypeScript support
- ESM + CommonJS support
📦 Installation
npm install live-logger-node⚡ Usage
import express from "express";
import { createLiveLogsMiddleware } from "live-logger-node";
const app = express();
app.use(express.json());
app.use(createLiveLogsMiddleware());
app.get("/", (_req, res) => {
console.log("Hello World");
res.send("Working");
});
app.listen(3000);🌐 Live Logs
Open:
http://localhost:3000/logs/live⚙️ Config
app.use(
createLiveLogsMiddleware({
route: "/logs/live",
logDir: "./logs",
logFile: "combined.log",
errorFile: "error.log",
maxLines: 10000,
captureConsole: true,
trimInterval: 30000,
})
);📘 Options
| Option | Type | Default | | -------------- | ------- | ------------ | | route | string | /logs/live | | logDir | string | ./logs | | logFile | string | combined.log | | errorFile | string | error.log | | maxLines | number | 10000 | | captureConsole | boolean | true | | trimInterval | number | 30000 |
📁 Generated Files
logs/
├── combined.log
└── error.log🔥 Captures
- console.log
- console.info
- console.warn
- console.error
- API requests
- uncaught exceptions
- unhandled promise rejections
🧠 Example Log
{
"type": "REQUEST",
"method": "POST",
"url": "/api/v1/users/login",
"status": 200,
"duration": "18ms"
}🚀 Build
npm run build👤 Author
Ankit Kumar
GitHub: https://github.com/connectankit
