Skip to content

feat: setup structured logging infrastructure - #343

Merged
OthmanImam merged 1 commit into
StellAIverse:mainfrom
kike-alt:feat/issue-310-structured-logging-infrastructure
Jun 23, 2026
Merged

feat: setup structured logging infrastructure#343
OthmanImam merged 1 commit into
StellAIverse:mainfrom
kike-alt:feat/issue-310-structured-logging-infrastructure

Conversation

@kike-alt

Copy link
Copy Markdown
Contributor

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 a x-correlation-id header 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 the logger config and LoggingMiddleware (8 tests, all passing).

Modified Files

  • src/app.module.ts — Registered LoggingMiddleware globally via NestModule.configure() for all routes.
  • src/config/logger.ts — Fixed circular dependency with tracing.ts by replacing the top-level import { getCurrentTraceId } with a lazy require() call inside the mixin function.
  • src/config/tracing.ts — Replaced all console.log/console.error calls with structured pino logger calls. Used lazy require('./logger') to avoid circular dependency.
  • src/common/database/database-index.service.ts — Replaced console.log/console.warn/console.error with structured logger calls.
  • src/oracle/submission-verifier.service.ts — Replaced console.warn with structured logger.warn call.

Validation Results

  • ✅ Build: webpack compiled successfully
  • ✅ New tests: 8/8 pass (logging.middleware.spec.ts)
  • ✅ No console.log/warn/error remaining in source code (excluding JSDoc comments)
  • ℹ️ Pre-existing test failures: 10 suites fail due to unrelated module resolution issues (Cannot find module 'src/...') — confirmed pre-existing on main before this PR

Closes

Closes #310

- 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)
@OthmanImam
OthmanImam merged commit e84a438 into StellAIverse:main Jun 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup Structured Logging Infrastructure

2 participants