🧹 Clean up logger utility by removing extra whitespace and simplifying arrow function syntax

This commit is contained in:
2026-01-29 13:19:05 +00:00
parent 2327557764
commit ee24b9bffc

View File

@@ -1,6 +1,6 @@
/** /**
* Production Logger with Winston * Production Logger with Winston
* *
* Provides structured logging for development and production environments. * Provides structured logging for development and production environments.
* - Console logging for development with colors * - Console logging for development with colors
* - File logging for production with rotation * - File logging for production with rotation
@@ -71,7 +71,7 @@ if (isProduction) {
maxFiles: 5 maxFiles: 5
}) })
); );
// Error logs // Error logs
logger.add( logger.add(
new winston.transports.File({ new winston.transports.File({
@@ -88,7 +88,7 @@ if (isProduction) {
*/ */
export function requestLogger(req, res, next) { export function requestLogger(req, res, next) {
const start = Date.now(); const start = Date.now();
// Log request // Log request
logger.info('HTTP Request', { logger.info('HTTP Request', {
method: req.method, method: req.method,
@@ -96,12 +96,12 @@ export function requestLogger(req, res, next) {
ip: req.ip, ip: req.ip,
userAgent: req.get('user-agent') userAgent: req.get('user-agent')
}); });
// Log response when finished // Log response when finished
res.on('finish', () => { res.on('finish', () => {
const duration = Date.now() - start; const duration = Date.now() - start;
const logLevel = res.statusCode >= 400 ? 'warn' : 'info'; const logLevel = res.statusCode >= 400 ? 'warn' : 'info';
logger[logLevel]('HTTP Response', { logger[logLevel]('HTTP Response', {
method: req.method, method: req.method,
url: req.url, url: req.url,
@@ -109,7 +109,7 @@ export function requestLogger(req, res, next) {
duration: `${duration}ms` duration: `${duration}ms`
}); });
}); });
next(); next();
} }
@@ -124,14 +124,14 @@ export function errorLogger(err, req, res, next) {
url: req.url, url: req.url,
body: req.body body: req.body
}); });
next(err); next(err);
} }
/** /**
* Log uncaught exceptions and unhandled rejections * Log uncaught exceptions and unhandled rejections
*/ */
process.on('uncaughtException', (error) => { process.on('uncaughtException', error => {
logger.error('Uncaught Exception', { logger.error('Uncaught Exception', {
error: error.message, error: error.message,
stack: error.stack stack: error.stack