diff options
Diffstat (limited to 'crates/config/src/file.rs')
| -rw-r--r-- | crates/config/src/file.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/config/src/file.rs b/crates/config/src/file.rs index a5ed559..b365623 100644 --- a/crates/config/src/file.rs +++ b/crates/config/src/file.rs @@ -14,7 +14,6 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, anyhow, bail}; use serde_json::{Map as JsonMap, Value as JsonValue}; -use tracing::debug; use crate::import; use crate::layer::{Entry, Layer, Overlay, Provenance, overlay, resolve_file_value, unset_entry}; @@ -59,7 +58,8 @@ fn load_inner(path: &Path, schema: &Schema, loading: &mut Vec<PathBuf>) -> Resul for (include, required) in includes { let include = dir.join(include); if !required && !include.exists() { - debug!(file = %include.display(), "Optional configuration file is missing; skipped"); + #[cfg(feature = "tracing")] + tracing::debug!(file = %include.display(), "Optional configuration file is missing; skipped"); continue; } let included = load_inner(&include, schema, loading) @@ -113,11 +113,18 @@ fn parse(path: &Path) -> Result<JsonMap<String, JsonValue>> { let text = std::fs::read_to_string(path).with_context(|| format!("reading {}", path.display()))?; let value: JsonValue = match path.extension().and_then(|e| e.to_str()) { + #[cfg(feature = "toml")] Some("toml") => { let value: toml::Value = toml::from_str(&text).with_context(|| format!("parsing {}", path.display()))?; serde_json::to_value(value).with_context(|| format!("converting {}", path.display()))? } + #[cfg(not(feature = "toml"))] + Some("toml") => bail!( + "{}: this program reads no TOML (it is built without the config crate's feature \ + toml): use .json", + path.display() + ), Some("json") => { serde_json::from_str(&text).with_context(|| format!("parsing {}", path.display()))? } |
