Console logging
Mellea usesFancyLogger, a color-coded singleton logger built on Python’s
logging module. All internal Mellea modules obtain their logger via
FancyLogger.get_logger().
Configuration
| Variable | Description | Default |
|---|---|---|
DEBUG | Set to any value to enable DEBUG-level output | unset (INFO level) |
FLOG | Set to any value to forward logs to a local REST endpoint at http://localhost:8000/api/receive | unset |
FancyLogger logs at INFO level with color-coded output to
stdout. Set the DEBUG environment variable to lower the level to DEBUG:
Log format
Console output uses ANSI color codes by log level:- Cyan — DEBUG
- Grey — INFO
- Yellow — WARNING
- Red — ERROR
- Bold red — CRITICAL
OTLP log export
When the[telemetry] extra is installed, Mellea can export logs to an OTLP
collector alongside the existing console output. This is useful for centralizing
logs from distributed services.
Note: OTLP logging is disabled by default. When disabled, there is zero overhead — no OTLP handler is created.
Enable OTLP logging
How it works
WhenMELLEA_LOGS_OTLP=true, FancyLogger adds an OpenTelemetry
LoggingHandler alongside its existing handlers:
- Console handler — continues to work normally (color-coded output)
- REST handler — continues to work normally (when
FLOGis set) - OTLP handler — exports logs to the configured OTLP collector
Programmatic access
Useget_otlp_log_handler() to add OTLP log export to your own loggers:
None when OTLP logging is disabled or not configured,
so the if handler check is always safe.
OTLP collector setup example
Integration with observability platforms
OTLP logs work with any OTLP-compatible platform:- Grafana Loki — log aggregation and querying
- Elasticsearch — log storage and analysis
- Datadog — unified logs, traces, and metrics
- New Relic — centralized logging
- Splunk — log analysis and monitoring
Performance
- Zero overhead when disabled: No OTLP handler is created, no performance impact.
- Batched export: Logs are batched and exported asynchronously.
- Non-blocking: Log export never blocks application code.
- Minimal overhead when enabled: OpenTelemetry’s efficient batching minimizes impact.
Troubleshooting
Logs not appearing in OTLP collector:- Verify
MELLEA_LOGS_OTLP=trueis set. - Check that an OTLP endpoint is configured
(
OTEL_EXPORTER_OTLP_ENDPOINTorOTEL_EXPORTER_OTLP_LOGS_ENDPOINT). - Verify the OTLP collector is running and configured to receive logs.
- Check collector logs for connection errors.
OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT.
Connection refused:
- Verify the OTLP collector is running:
docker ps | grep otel - Check the endpoint URL is correct (default:
http://localhost:4317). - Verify network connectivity:
curl http://localhost:4317
See also: