Skip to content

Diagnostic logging #13204

@florianleibert

Description

@florianleibert

Task: Diagnostic logging

Description

Implement the diagnostic log file system for quality monitoring. Supports three verbosity levels (minimal, normal, verbose), configurable log path, and automatic rotation to prevent unbounded disk usage.

Acceptance Criteria

  • packages/opencode/src/quality/logger.ts created
  • Log file created at configurable path (default: .opencode/quality.log)
  • Three log levels:
    • minimal: score and model ID only (one line per response)
    • normal: score breakdown, diagnostic notes, regression alerts
    • verbose: full prompt summary, response summary, all metadata
  • Log entries are structured with: timestamp, session_id, model_id, level-appropriate content
  • Log rotation: when file exceeds configurable max size (default: 50MB), rotate to .log.1, .log.2, .log.3, delete oldest
  • Logging toggleable via quality.logging config (default: true)
  • Log level controlled via quality.logLevel config
  • Logger called from scoring pipeline after each score computation
  • Logger is non-blocking — writes are buffered/async
  • Logger handles file I/O errors gracefully (warn once, don't spam)

Technical Details

  • Use Bun.file() and Bun.write() for efficient file I/O
  • Append mode for normal writes, rotate when size threshold crossed
  • Rotation check: stat the file size before each write batch, rotate if over limit
  • For verbose level: truncate prompt/response to first 500 chars to keep logs manageable
  • Expose QualityLogger.log(entry) as main API, called from scorer.ts after scoring

Dependencies

  • Task 002: Quality configuration (for log settings)
  • Task 003: Scoring engine (provides data to log)

Effort Estimate

  • Size: S
  • Hours: 3-4
  • Parallel: true (can run alongside 004, 005)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions