Files
aurorabot/.agent/work/tickets/002-centralized-error-logging.md
2026-01-14 16:10:23 +01:00

1.2 KiB

Context & Goal

The bot currently relies on console.error which is hard to track and lacks context. A centralized error logging service will allow for better debugging, persistent error logs, and future integration with services like Sentry or Discord webhooks for alerts.

Dependencies

  • None

Affected Files

  • shared/lib/logger.ts: New file for the unified logger service.
  • bot/lib/handlers/CommandHandler.ts: Update to use the new logger for command errors.
  • web/src/server.ts: Update to use the new logger for API and WebSocket errors.

Technical Constraints & Strategy

  • Implementation: Create a Logger class/object in shared/lib.
  • Support log levels: info, warn, error, debug.
  • Errors should capture: timestamp, source (bot/web), error message, and stack trace if available.
  • For now, logging to console and a local log file (e.g., logs/error.log) is sufficient.

Definition of Done (Binary)

  • Logger service implemented in shared/lib/logger.ts.
  • Command errors are logged via the new service.
  • Web server errors are logged via the new service.
  • Log output is formatted consistently.

New Test Files

  • shared/lib/logger.test.ts: Verify logger output and file writing.