You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
TariffShield currently uses bare console.log calls with no structure, correlation IDs, or log levels, making it impossible to trace requests across services or filter logs by severity in production. Every API request, error, and Soroban RPC call needs a consistent JSON log line with a request-scoped correlation ID so operators can reconstruct the full lifecycle of any transaction. Without structured logging, debugging production incidents requires guesswork rather than log queries.
Acceptance Criteria:
Install pino and pino-http as production dependencies; install pino-pretty as a dev dependency for local formatting
Mount pino-http middleware in apps/api/src/index.ts before all route handlers so every HTTP request logs method, path, status code, response time, and correlationId
Generate a UUID v4 correlationId per request (via pino-http's genReqId option) and attach it to req.log so child loggers in downstream handlers inherit it automatically
Replace all console.log / console.error calls in apps/api/src/routes/importers.ts and apps/api/src/stellar.ts with req.log.info / req.log.error child loggers
Set log level via LOG_LEVEL environment variable (default info); support trace, debug, info, warn, error, fatal
Emit JSON output in production (NODE_ENV=production) and pretty-printed output in development via pino-pretty transport
Log Soroban RPC call duration in milliseconds on every call in apps/api/src/stellar.ts with fields { rpcMethod, durationMs, success }
Relevant Files:
apps/api/src/index.ts — mount pino-http middleware here
apps/api/src/routes/importers.ts — replace console calls with structured child logger
apps/api/src/stellar.ts — instrument RPC calls with duration logging
apps/api/src/db.ts — replace any console calls with structured logger
Description:
TariffShield currently uses bare
console.logcalls with no structure, correlation IDs, or log levels, making it impossible to trace requests across services or filter logs by severity in production. Every API request, error, and Soroban RPC call needs a consistent JSON log line with a request-scoped correlation ID so operators can reconstruct the full lifecycle of any transaction. Without structured logging, debugging production incidents requires guesswork rather than log queries.Acceptance Criteria:
pinoandpino-httpas production dependencies; installpino-prettyas a dev dependency for local formattingpino-httpmiddleware inapps/api/src/index.tsbefore all route handlers so every HTTP request logs method, path, status code, response time, andcorrelationIdcorrelationIdper request (viapino-http'sgenReqIdoption) and attach it toreq.logso child loggers in downstream handlers inherit it automaticallyconsole.log/console.errorcalls inapps/api/src/routes/importers.tsandapps/api/src/stellar.tswithreq.log.info/req.log.errorchild loggersLOG_LEVELenvironment variable (defaultinfo); supporttrace,debug,info,warn,error,fatalNODE_ENV=production) and pretty-printed output in development viapino-prettytransportapps/api/src/stellar.tswith fields{ rpcMethod, durationMs, success }Relevant Files:
apps/api/src/index.ts— mountpino-httpmiddleware hereapps/api/src/routes/importers.ts— replace console calls with structured child loggerapps/api/src/stellar.ts— instrument RPC calls with duration loggingapps/api/src/db.ts— replace any console calls with structured logger