Expand description
Logging and progress display utilities.
This module provides structured logging for Ralph’s pipeline:
Loggerstruct for consistent, colorized output- Progress bar display
- Section headers and formatting
- Colors & Formatting for terminal output
- Test utilities for capturing log output in tests
§Example
ⓘ
use ralph::logger::Logger;
use ralph::logger::Colors;
let colors = Colors::new();
let logger = Logger::new(colors)
.with_log_file(".agent/logs/pipeline.log");
logger.info("Starting pipeline...");
logger.success("Task completed");
logger.warn("Potential issue detected");
logger.error("Critical failure");§Testing with TestLogger
For testing purposes, the output module provides TestLogger which implements
the same traits as Logger (Printable and std::io::Write) for output capture.
ⓘ
use ralph::logger::output::TestLogger;
use std::io::Write;
let logger = TestLogger::new();
writeln!(logger, "Test message").unwrap();
assert!(logger.has_log("Test message"));
let logs = logger.get_logs();
assert_eq!(logs.len(), 1);§Trait Implementation
Both Logger and TestLogger implement:
Loggabletrait - provides unified interface for log output (info, success, warn, error)Printabletrait fromjson_parser::printer- enables terminal detectionstd::io::Writetrait - enables writing to the logger
The Loggable trait mirrors the Printable trait pattern used for printers,
providing a consistent API for both production (Logger) and test (TestLogger) scenarios.
Structs§
Constants§
- ARROW
- Icons for output
- BOX_BL
- BOX_BR
- BOX_H
- BOX_TL
- Box-drawing characters for visual structure
- BOX_TR
- BOX_V
- CHECK
- CROSS
- INFO
- WARN
Traits§
- Loggable
- Trait for logger output destinations.
Functions§
- argv_
requests_ json - Detect if command-line arguments request JSON output.
- colors_
enabled - Check if colors should be enabled
- format_
generic_ json_ for_ display - Format generic JSON output for display.
- print_
progress - Print a progress bar with percentage and counts.