Skip to content

⚙️ Infrastructure: Persistent Logging to PostgreSQL #54

@BillChirico

Description

@BillChirico

Add a PostgreSQL transport to Winston so bot logs are persisted to the database alongside file/console output.

Requirements

  • Custom Winston transport that writes log entries to a PostgreSQL table
  • Log table schema: id, level, message, metadata (JSONB), timestamp
  • Configurable via config.json (enable/disable, min log level for DB, retention days)
  • Auto-prune old logs based on retention config
  • Query endpoint or utility for viewing logs (for future dashboard integration)
  • Should not block or slow down the bot if DB is unavailable — fail gracefully
  • Respect existing log levels and structured metadata already in use

Implementation Notes

  • Use the existing db.js pool — no separate connection
  • Migration: CREATE TABLE IF NOT EXISTS on startup
  • Consider batch inserts to reduce DB round-trips
  • Index on timestamp + level for efficient querying
  • Dashboard task will eventually consume these logs

Acceptance Criteria

  • Logs written to PostgreSQL
  • Configurable retention and pruning
  • No performance impact when DB unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions