29 lines
1.0 KiB
Rust
29 lines
1.0 KiB
Rust
|
|
//! Common diagnostics helpers (concise, centralized)
|
||
|
|
|
||
|
|
/// Whether provider logs should be emitted under current policy.
|
||
|
|
/// quiet_pipe usually reflects NYASH_JSON_ONLY; allowing override with HAKO_PROVIDER_TRACE=1.
|
||
|
|
pub fn provider_log_enabled(quiet_pipe: bool) -> bool {
|
||
|
|
!quiet_pipe || std::env::var("HAKO_PROVIDER_TRACE").as_deref() == Ok("1")
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Emit a consistent provider-registry info line.
|
||
|
|
pub fn provider_log_info(msg: &str) {
|
||
|
|
eprintln!("[provider-registry] {}", msg);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Emit the provider selection tag in a stable shape.
|
||
|
|
pub fn provider_log_select(box_name: &str, ring: &str, source: &str, caps: Option<&str>) {
|
||
|
|
match caps {
|
||
|
|
Some(c) if !c.is_empty() => {
|
||
|
|
eprintln!("[provider/select:{} ring={} src={} caps={}]", box_name, ring, source, c);
|
||
|
|
}
|
||
|
|
_ => {
|
||
|
|
eprintln!("[provider/select:{} ring={} src={}]", box_name, ring, source);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Emit a Fail-Fast tag for provider fallback/selection errors.
|
||
|
|
pub fn failfast_provider(reason: &str) { eprintln!("[failfast/provider/{}]", reason); }
|
||
|
|
|