forked from syntaxbullet/aurorabot
1.2 KiB
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
Loggerclass/object inshared/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)
Loggerservice implemented inshared/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.