Skip to content

Logging cleanup#42

Merged
dantheuber merged 2 commits into
mainfrom
logging-cleanup
Mar 4, 2026
Merged

Logging cleanup#42
dantheuber merged 2 commits into
mainfrom
logging-cleanup

Conversation

@dantheuber
Copy link
Copy Markdown
Member

Summary

Replaces all console.log/warn/error calls across the server codebase with the structured pino logger, fixes all ESLint errors, and silences log output during tests — eliminating noisy, non-meaningful output from test runs.

Changes

Lint fixes

  • Fixed 3 prefer-const errors in alertMutes.ts and mutes/list.ts by restructuring let assignments to inline const

Logging migration (console → pino logger)

  • 15 route handlers migrated from manual console.error + res.status().json() to the centralized sendErrorResponse utility
  • Auth routes (login.ts, logout.ts, callback.ts) now use logger.error/warn/info instead of console.*
  • HealthPollingService.ts: all 8 console.log calls replaced with structured logger.info
  • auth/config.ts, auth/session.ts, auth/validateSessionSecret.ts: console.log/warnlogger.info/warn
  • db/index.ts, db/migrate.ts: console.loglogger.info

Error handling improvements

  • errors.ts: errorHandler, wrapHandler, and sendErrorResponse now only log 5xx errors via logger.error — expected 4xx errors (validation, not-found) no longer produce log output
  • Eliminates the main source of noisy test output: route handler tests triggering expected validation errors

Test output silencing

  • Added LOG_LEVEL=silent to server/jest.config.js to suppress all pino output during tests
  • Updated test files (errors.test.ts, config.test.ts, warnInsecureCookies.test.ts, validateSessionSecret.test.ts, HealthPollingService.test.ts) to mock the logger module instead of spying on console.*

Testing

  • New/updated tests included
  • All tests pass (npm test)
  • Linting passes (npm run lint)

Checklist

@dantheuber dantheuber merged commit cc428c1 into main Mar 4, 2026
3 checks passed
@dantheuber dantheuber deleted the logging-cleanup branch March 4, 2026 03:57
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.

1 participant