Skip to content

Add backend request logging hook#142

Draft
dangzitou wants to merge 1 commit into
Dev-Card:mainfrom
dangzitou:openmeta/agent-8-backend-add-request-logging-midd-1779072191456
Draft

Add backend request logging hook#142
dangzitou wants to merge 1 commit into
Dev-Card:mainfrom
dangzitou:openmeta/agent-8-backend-add-request-logging-midd-1779072191456

Conversation

@dangzitou
Copy link
Copy Markdown

Summary

Backend requests currently do not emit a lightweight per-request log containing the HTTP method and path, making endpoint activity harder to trace. This PR adds a global Fastify onRequest hook in the backend app that logs each incoming request through the existing pino-backed app logger, then adds test coverage to verify the hook runs for injected requests.

Changes

  • Add a global Fastify onRequest hook in apps/backend/src/app.ts that logs the incoming request method and URL/path using app.log.info.
  • Use the existing Fastify/pino logger so request logs remain consistent with current backend logging output.
  • Add app-level test coverage in apps/backend/src/tests/app.test.ts that spies on app.log.info and asserts an injected request emits the expected method and path payload.

Validation

  • pnpm run test is the detected test command; not executed yet and still pending in this environment.
  • pnpm run lint is the detected lint command; not executed yet and still pending in this environment.

Risks

  • The log field uses request.url, which may include query strings; this matches Fastify behavior but may be broader than a strict path-only value.
  • Tests that spy on app.log.info may be sensitive to Fastify or pino logger binding behavior.
  • If buildApp registers external database or cache plugins during tests, mocks may be needed to avoid requiring external services.

@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label May 18, 2026
@Harxhit
Copy link
Copy Markdown
Collaborator

Harxhit commented May 18, 2026

@dangzitou Please join our Discord community from the README section so we can communicate properly and provide valid labels for your contributions, which will help you score points in GSSoC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants