Ferrite v0.2.2 introduces configurable log levels, allowing users to control the verbosity of log output. This addresses GitHub Issue #11.
| File | Purpose |
|---|---|
src/config/settings.rs |
LogLevel enum and log_level field in Settings |
src/main.rs |
CLI flag parsing and logging initialization |
docs/cli.md |
CLI documentation with --log-level usage |
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase")]
pub enum LogLevel {
Debug, // Most verbose
Info, // Informational messages
#[default]
Warn, // Warnings and errors (default)
Error, // Errors only
Off, // Disable logging
}display_name()- Human-readable name for UI/loggingdescription()- Detailed description for tooltipsall()- List of all available levelsto_level_filter()- Convert tolog::LevelFilterfor env_logger
Log level is determined in this order (highest priority first):
- CLI flag -
ferrite --log-level debug - Config file -
"log_level": "debug"in config.json - Built-in default -
warn
// 1. Parse CLI arguments
let cli = Cli::parse();
// 2. Load config (includes log_level)
let settings = load_config();
// 3. Determine effective log level
let effective_log_level = cli.log_level.unwrap_or(settings.log_level);
// 4. Initialize logging
env_logger::Builder::new()
.filter_level(effective_log_level.to_level_filter())
.init();# Enable debug logging
ferrite --log-level debug
# Show only errors
ferrite --log-level error
# Disable all logging
ferrite --log-level off
# Combine with file arguments
ferrite --log-level debug README.mdIn config.json:
{
"log_level": "warn"
}Valid values: debug, info, warn, error, off
- Uses
#[serde(default)]so existing config files withoutlog_leveldefault towarn - Invalid values in config file cause deserialization to use default
- CLI parser accepts aliases:
warning→warn,none→off
Run log level tests:
cargo test config::settings::tests::test_log_levelTests cover:
- Default value (
Warn) - Serialization/deserialization
- All enum variants
- Backward compatibility with old config files
- Level filter conversion
- CLI Reference - Full CLI documentation
- Settings & Config - Settings system overview
- GitHub Issue #11 - Original feature request