express-api-tracer
v1.0.0
Published
A lightweight Express middleware for logging API requests with color coded terminal output and file logging
Readme
express-api-tracer
A lightweight Express middleware for tracing and logging API requests with color coded terminal output and persistent file logging.
Installation
npm install express-api-tracerUsage
const express = require('express')
const logger = require('express-api-tracer')
const app = express()
app.use(logger())
app.get('/api/test', (req, res) => {
res.send('hello')
})
app.listen(3000)Output
Terminal output is color coded by status code:
- 🟢 Green — 2xx Success
- 🟡 Yellow — 4xx Client Error
- 🔴 Red — 5xx Server Error
Each request is logged in this format:
15/01/2024 10:23:45 | GET | /api/test | 2ms | 200File Logging
Every request is automatically saved to access.log in your project root for permanent history.
License
ISC
