Skip to content

Commit

Permalink
Merge pull request emabee#66 from ijackson/allow-empty-spec
Browse files Browse the repository at this point in the history
Allow absence of [modules] in TOML file.
  • Loading branch information
emabee authored Sep 20, 2020
2 parents c321bbf + 1211a5f commit 0bfd3c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/log_specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl LogSpecification {
struct LogSpecFileFormat {
pub global_level: Option<String>,
pub global_pattern: Option<String>,
pub modules: std::collections::BTreeMap<String, String>,
pub modules: Option<std::collections::BTreeMap<String, String>>,
}

let logspec_ff: LogSpecFileFormat = toml::from_str(s)?;
Expand All @@ -266,7 +266,7 @@ impl LogSpecification {
});
}

for (k, v) in logspec_ff.modules {
for (k, v) in logspec_ff.modules.unwrap_or_default() {
module_filters.push(ModuleFilter {
module_name: Some(k),
level_filter: parse_level_filter(v)?,
Expand Down Expand Up @@ -872,6 +872,11 @@ mod test_with_specfile {

#[test]
fn specfile() {
compare_specs(
"",
"",
);

compare_specs(
"[modules]\n\
",
Expand Down

0 comments on commit 0bfd3c7

Please sign in to comment.