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