Skip to content

refactor: Implement proper logging strategy #25

@greynewell

Description

@greynewell

Problem

The codebase has many `console.error('[DEBUG] ...')` statements for informational logging. Issues:

  1. Debug logs go to stderr - Informational messages should use stdout
  2. No log levels - Can't distinguish info/warn/error/debug
  3. Always enabled - No way to disable debug logging in production
  4. Inconsistent format - Some use [DEBUG], [ERROR], [WARN], some don't

Proposed Solution

Either:

Option 1: Simple - Environment Variable

const DEBUG = process.env.DEBUG === 'true';

function debug(msg: string, ...args: any[]) {
  if (DEBUG) console.error('[DEBUG]', msg, ...args);
}

function info(msg: string, ...args: any[]) {
  console.log('[INFO]', msg, ...args);
}

Option 2: Structured Logger
Use a library like pino or winston for proper log levels, structured output, and configuration.

Benefits

  • Cleaner production logs
  • Configurable verbosity
  • Better debugging experience
  • Consistent log format

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions