Skip to content

Add Pino logging to governance API#776

Merged
lukozill merged 1 commit into
mainfrom
users/lukasz/governance_portal_fix
May 26, 2026
Merged

Add Pino logging to governance API#776
lukozill merged 1 commit into
mainfrom
users/lukasz/governance_portal_fix

Conversation

@lukozill
Copy link
Copy Markdown
Contributor

Summary

Introduces structured JSON logging across the governance-api service using
pino and pino-http, replacing all unstructured console.log/console.info
calls. This makes incident investigation possible by capturing every
significant runtime event with enough context to diagnose failures without
reproduction.

Changes

  • lib/logger.ts — new shared pino logger singleton used throughout
    the service.
  • lib/app.ts — installs pino-http middleware; responses with HTTP
    status ≥ 400 are logged at error level, all others at info.
  • lib/server.ts — startup is wrapped in try/catch; DB sync and
    successful bind emit logger.info; any startup failure emits
    logger.error and exits with code 1.
  • lib/routes/message.ts — every validation-failure 400 path now
    emits log.error with an error_code field before responding; each
    successful processing step (signature verified, liquidity fetched, DB
    record created) emits log.info; final console.log replaced.
  • lib/routes/spaces.ts — both async route handlers wrapped in
    try/catch; DB errors emit logger.error and return a 500 instead of an
    unhandled promise rejection.
  • lib/utils/pin-ipfs.ts — IPFS pin success logged at info for
    both Pinata and local-node paths; pin failure logged at error before
    throwing.
  • lib/zilliqa/custom-fetch.ts — Zilliqa RPC call wrapped in
    try/catch with error log on failure; successful liquidity fetch logged
    at info; XCAD and ZilSwap parse errors use logger.error instead of
    console.log.
  • package.json — adds pino and pino-http as runtime deps;
    pino-pretty and @types/pino-http as dev deps; TypeScript bumped to
    3.9.x.

Test plan

  • Start the service in Docker and confirm it boots without errors and
    emits a structured "Server started" log line.
  • Submit a valid proposal via POST /api/message and confirm that adequate message appear in logs.
  • Hit GET /api/:space/proposals and confirm the request is logged by
    pino-http.

@lukozill lukozill enabled auto-merge (squash) May 25, 2026 19:53
@lukozill lukozill merged commit 9cf6cc6 into main May 26, 2026
3 checks passed
@lukozill lukozill deleted the users/lukasz/governance_portal_fix branch May 26, 2026 08:56
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.

2 participants