//! 运行日志:日志级别与日志条目。 #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum LogLevel { Debug, Info, Warn, Error, } impl LogLevel { pub fn label(self) -> &'static str { match self { Self::Debug => "DEBUG", Self::Info => "INFO", Self::Warn => "WARN", Self::Error => "ERROR", } } pub fn parse(s: &str) -> Self { match s { "debug" => Self::Debug, "warn" => Self::Warn, "error" => Self::Error, _ => Self::Info, } } } #[derive(Debug, Clone)] pub struct LogEntry { pub timestamp: i64, pub connection_id: String, pub level: LogLevel, pub event: String, pub message: String, pub details: Option, } // ─── 连接状态 ────────────────────────────────────────────────────────────────