Skip to content

Commit

Permalink
Fix derserialize config.toml (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n authored Jun 2, 2024
1 parent a07cc1d commit 9ca2742
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ mod serde_log_level_filter {
where
D: Deserializer<'de>,
{
let level = <&str>::deserialize(deserializer)?;
parse_log_level_str::<D>(level)
let level = String::deserialize(deserializer)?;
parse_log_level_str::<D>(level.as_str())
}
}

Expand Down Expand Up @@ -806,3 +806,16 @@ pub fn set_logger(level: Option<tracing::level_filters::LevelFilter>) {
crate::tracing::tracer::init_tracer(level).expect("failed tracing initialization")
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_serde() {
let args = ConfigArgs::default();
let cfg = args.build().unwrap();
let serialized = toml::to_string(&cfg).unwrap();
let _: Config = toml::from_str(&serialized).unwrap();
}
}

0 comments on commit 9ca2742

Please sign in to comment.