初始化 Panda RPKI v0.1.0 开源候选版本
Some checks failed
ci / rust (push) Has been cancelled
ci / docker (push) Has been cancelled

This commit is contained in:
Panda RPKI OSS Local
2026-09-09 18:01:15 +08:00
commit 277cbca878
203 changed files with 92495 additions and 0 deletions

72
src/logging/progress.rs Normal file
View File

@@ -0,0 +1,72 @@
// Event sites construct detailed payloads lazily.
macro_rules! emit {
($kind:expr, $payload:expr $(,)?) => {
crate::logging::emit(crate::logging::progress::event_level($kind), $kind, || {
$payload
})
};
}
pub(crate) use emit;
pub(crate) fn event_level(kind: &str) -> crate::logging::Level {
if matches!(kind, "http_fetch_failed" | "rrdp_sync_failed") {
crate::logging::Level::Warn
} else if kind == "validation_failed" || kind.ends_with("_failed") || kind.starts_with("error_")
{
crate::logging::Level::Error
} else if kind.ends_with("_warning")
|| kind.ends_with("_warnings")
|| kind.starts_with("warning_")
{
crate::logging::Level::Warn
} else if kind.starts_with("publication_point")
|| kind.starts_with("phase2_")
|| kind.starts_with("object_")
{
crate::logging::Level::Trace
} else if kind.starts_with("validation_")
|| kind.starts_with("run_")
|| kind.starts_with("output_")
|| kind.starts_with("ccr_")
|| kind.ends_with("_summary")
{
crate::logging::Level::Info
} else {
crate::logging::Level::Debug
}
}
pub fn slow_threshold_secs() -> f64 {
30.0
}
pub fn stage_fresh_slow_threshold_ms() -> u64 {
1_000
}
pub fn pp_control_slow_threshold_ms() -> u64 {
100
}
pub fn control_loop_slow_threshold_ms() -> u64 {
1_000
}
#[cfg(test)]
mod tests {
use super::event_level;
use crate::logging::Level;
#[test]
fn event_levels_keep_default_output_quiet() {
assert_eq!(event_level("validation_started"), Level::Info);
assert_eq!(event_level("repository_sync_selected"), Level::Debug);
assert_eq!(event_level("publication_point_object"), Level::Trace);
assert_eq!(event_level("validation_warning"), Level::Warn);
assert_eq!(event_level("validation_warnings"), Level::Warn);
assert_eq!(event_level("validation_failed"), Level::Error);
assert_eq!(event_level("object_failed"), Level::Error);
assert_eq!(event_level("http_fetch_failed"), Level::Warn);
assert_eq!(event_level("rrdp_sync_failed"), Level::Warn);
}
}