feat(config): add [logging] section (ingest_log_enabled + ingest_log_dir)

v0.20.x ingest log surface 의 config side. LoggingCfg struct 신설:
  * ingest_log_enabled (bool, default true)
  * ingest_log_dir (PathBuf, default "{state_dir}/logs")

#[serde(default)] tag 로 pre-v0.20 config 가 [logging] section 부재
시 LoggingCfg::default() 자동 init (AC-10 backward compat).

{state_dir} placeholder 의 실제 expand 는 step 2 (IngestLogWriter)
의 expand_log_dir helper 가 담당 (kebab-config 의 expand_path_with_base
는 {state_dir} 미지원, spec §6 R-3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-28 02:44:21 +00:00
parent 6a9551e0fa
commit f60304beb4
2 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// crates/kebab-config/tests/logging_roundtrip.rs
//
// Integration tests for [logging] config section (v0.20.x ingest log feature).
use std::path::PathBuf;
use kebab_config::{Config, LoggingCfg};
#[derive(serde::Deserialize)]
struct LoggingWrapper { logging: LoggingCfg }
// Test 1: default LoggingCfg roundtrip — enabled=true, dir="{state_dir}/logs".
#[test]
fn logging_defaults_are_enabled_with_state_dir_placeholder() {
let cfg = Config::defaults();
assert!(cfg.logging.ingest_log_enabled);
assert_eq!(cfg.logging.ingest_log_dir, PathBuf::from("{state_dir}/logs"));
}
// Test 2: [logging] override — enabled=false, custom dir.
#[test]
fn logging_toml_override() {
let toml = r#"
[logging]
ingest_log_enabled = false
ingest_log_dir = "/tmp/custom-logs"
"#;
let w: LoggingWrapper = toml::from_str(toml).expect("parse toml");
assert!(!w.logging.ingest_log_enabled);
assert_eq!(w.logging.ingest_log_dir, PathBuf::from("/tmp/custom-logs"));
}
// Test 3: pre-v0.20 config (no [logging] section) → LoggingCfg::default() (AC-10).
#[test]
fn pre_v020_config_without_logging_section_gets_defaults() {
let toml = r#"
[logging]
"#;
let w: LoggingWrapper = toml::from_str(toml).expect("parse toml with empty logging section");
assert!(w.logging.ingest_log_enabled);
assert_eq!(w.logging.ingest_log_dir, PathBuf::from("{state_dir}/logs"));
}