Merged
Conversation
TienNguyen3711
requested changes
Mar 31, 2026
Collaborator
There was a problem hiding this comment.
It would be stronger if we enforced a more consistent schema across all logs, especially fields like requestId, endpoint, method, and statusCode.
Collaborator
There was a problem hiding this comment.
I’d recommend also returning the requestId in a response header and ensuring downstream services consistently include it in their logs for end-to-end traceability
Collaborator
There was a problem hiding this comment.
It currently overlaps with errorLogService. It would be better to consolidate on a single structured logging path so error logs do not end up split across different formats.
TienNguyen3711
approved these changes
Apr 2, 2026
Collaborator
|
Please resolve the merge conflict. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implemented centralized structured logging across the NutriHelp API backend to improve traceability, observability, and production debugging.
New Files
utils/logger.js – Centralized Winston-based structured logger (163 lines)
middleware/requestLogger.js – HTTP request/response logging middleware (83 lines)
middleware/structuredErrorHandler.js – Structured error handling middleware (79 lines)
Modified Files
server.js – Integrated request logger and error handler middleware
package.json – Added Winston dependency
10 controllers updated: authController, appointmentController, chatbotController, homeServiceController, imageClassificationController, loginController, medicalPredictionController, notificationController, uploadController, userPreferencesController
Changes
Every HTTP request logged with timestamp, method, endpoint, status code, and duration
Errors captured in consistent structured format with stack traces where appropriate
Environment-aware logging, readable in dev, concise and structured in production
Replaced unstructured console.log calls across all major controllers