coojar-logger
v1.0.9
Published
Coojar Logger is a versatile Node.js middleware package designed to streamline request/response logging, header masking, and error handling within HTTP servers.
Downloads
6
Readme
Coojar Logger is a versatile Node.js middleware package designed to streamline request/response logging, header masking, and error handling within HTTP servers.
Features
- Header Masking: Conceals sensitive headers in incoming and outgoing HTTP requests.
- Request/Response Logging: Captures and logs request and response details, including method, URL, duration, status code, and masked headers.
- Error Handling: Logs errors occurring during request processing.
- Flexible Configuration: Easy integration and customizable options.
Installation
Install the package via npm:
npm install coojar-logger
Usage
const middlewareLogger = require('coojar-logger');
// ...your existing middleware stack setup
// Add middlewareLogger to your stack
app.use(middlewareLogger());
Example
const express = require('express');
const middlewareLogger = require('coojar-logger');
const app = express();
// Add middlewareLogger to your Express app
app.use(middlewareLogger());
// ...other middleware and routes
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
Configuration Options
The middleware supports configuration through options, although the default setup works seamlessly for most cases.