feat: setup structured logging infrastructure - #343
Merged
OthmanImam merged 1 commit intoJun 23, 2026
Merged
Conversation
- Add LoggingMiddleware for request/response logging with correlation IDs - Register LoggingMiddleware globally in AppModule - Fix circular dependency between logger.ts and tracing.ts via lazy require - Replace all console.log/warn/error calls with pino logger - Add unit tests for logger config and LoggingMiddleware (8 tests)
6 tasks
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.
Summary
Implements structured logging infrastructure using Pino as required by issue #310.
Implementation Details
New Files
src/common/middleware/logging.middleware.ts— Request/response logging middleware that attaches ax-correlation-idheader to every request (reuses existing header if provided), logs incoming requests and response completions with method, URL, status code, duration, and IP.src/common/middleware/logging.middleware.spec.ts— Unit tests for both theloggerconfig andLoggingMiddleware(8 tests, all passing).Modified Files
src/app.module.ts— RegisteredLoggingMiddlewareglobally viaNestModule.configure()for all routes.src/config/logger.ts— Fixed circular dependency withtracing.tsby replacing the top-levelimport { getCurrentTraceId }with a lazyrequire()call inside the mixin function.src/config/tracing.ts— Replaced allconsole.log/console.errorcalls with structuredpinologger calls. Used lazyrequire('./logger')to avoid circular dependency.src/common/database/database-index.service.ts— Replacedconsole.log/console.warn/console.errorwith structuredloggercalls.src/oracle/submission-verifier.service.ts— Replacedconsole.warnwith structuredlogger.warncall.Validation Results
webpack compiled successfullylogging.middleware.spec.ts)console.log/warn/errorremaining in source code (excluding JSDoc comments)Cannot find module 'src/...')— confirmed pre-existing onmainbefore this PRCloses
Closes #310