Skip to content

Enhance MelleaLogger with additional logging handlers for flexible log routing to multiple destinations: stdout (console), file, OTLP logs endpoint, and HTTP webhooks #460

@psschwei

Description

@psschwei

Description:
Enhance MelleaLogger with additional logging handlers for flexible log routing to multiple destinations: stdout (console), file, OTLP logs endpoint, and HTTP webhooks.

Detailed Requirements:

  1. Add new handlers to MelleaLogger in mellea/core/utils.py:
    • RotatingFileHandler - File output with rotation (use stdlib logging.handlers)
    • OTLPLogHandler - OpenTelemetry Logs Protocol exporter (custom handler)
    • Keep existing RESTHandler for webhook support
  2. Create handler configuration function:
    • configure_logging() - Set up handlers based on environment
    • Called automatically on first get_logger() call
  3. Configuration via environment variables:
    • MELLEA_LOG_CONSOLE=true/false (default: true)
    • MELLEA_LOG_FILE=/path/to/logs/mellea.log
    • MELLEA_LOG_FILE_MAX_BYTES=10485760 (default: 10MB)
    • MELLEA_LOG_FILE_BACKUP_COUNT=5 (default: 5)
    • MELLEA_LOG_OTLP=true/false
    • MELLEA_LOG_WEBHOOK=http://endpoint (replaces FLOG env var)
  4. Support JSON and human-readable formats per handler
  5. Ensure all handlers receive trace context and Mellea context via filters

Files to Modify:

  • mellea/core/utils.py - Add handlers and configuration function

Acceptance Criteria:

  • Console handler with colored and JSON output options
  • File handler with rotation support
  • OTLP handler sends structured logs to collector
  • Multiple handlers can be active simultaneously
  • All handlers receive trace and context data via filters
  • Handlers configurable via environment variables

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions