Skip to content

Replace console.error with structured logging system (Winston/Pino) #67

@cursor

Description

@cursor

Description

The audit found that the codebase uses console.error throughout for error logging. This is not suitable for production and makes error tracking difficult.

Context

Current state:

  • console.error used in 30+ API routes
  • No log levels (debug, info, warn, error)
  • No centralized logging
  • No structured logs (JSON)
  • Logs remain in production

Requirements

  1. Choose Logging Library

    • Winston or Pino (recommended: Pino for performance)
    • Configure for different environments
  2. Implement Logging Utility

    • Create src/lib/logger.ts
    • Support different log levels
    • Structured JSON output
    • Environment-based configuration
  3. Replace console.error

    • Find all console.error calls
    • Replace with logger.error()
    • Add context and metadata
  4. Production Configuration

    • Remove console.* in production
    • Configure log levels
    • Set up log aggregation (optional)

Acceptance Criteria

  • Logging library installed
  • Logger utility created
  • All console.error replaced
  • Log levels configured
  • Structured JSON logs in production
  • No console.* in production code

Related

Priority

High - Critical for production monitoring

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions