feat: add structured logging with Winston, Morgan, and request correlation IDs#466
Merged
Nsanjayboruds merged 4 commits intoJul 13, 2026
Merged
Conversation
…ing code from index.js
…st correlation IDs
…with centralized logger
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.
Description
Fixes #426.
This PR introduces a centralized and structured logging system by replacing the existing ad-hoc
console.log/console.errorusage and manual request logging with Winston for application logs, Morgan for HTTP access logs, and request correlation IDs for improved traceability.Changes
backend/config/logger.js(new)LOG_LEVELenvironment variable (defaults toinfo).backend/middleware/requestId.js(new)crypto.randomUUID().req.id.X-Request-Idresponse header.backend/app.jsbackend/index.jsconsole.logstatements withlogger.info.app.jsremains the single source of truth for application routes and middleware.backend/config/db.jsconsole.log/console.errorstatements with the centralized logger.backend/routes/bot.jslogger.error()messages containing the request ID and error message only.Remaining backend files
console.logandconsole.errorstatements throughout the backend with the centralized Winston logger to provide consistent logging across the application.Testing
Verified locally that:
console.log.X-Request-Idresponse header matches the correlation ID shown in the corresponding log entries.logger.errorentry without exposing any secrets.console.logandconsole.errorusages have been replaced with the centralized logger.Branch Note
This branch is based on
fix/415-index-startup-crashbecausemaincurrently cannot start the server (see #415). Once #415 is merged, this branch can be rebased onto the updatedmain, which will remove the unrelated startup-fix changes from this PR.Checklist
console.log/console.errorLOG_LEVELenvironment variable