diff options
Diffstat (limited to 'crates/config/src/layer.rs')
| -rw-r--r-- | crates/config/src/layer.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/config/src/layer.rs b/crates/config/src/layer.rs index 783bcb0..6693009 100644 --- a/crates/config/src/layer.rs +++ b/crates/config/src/layer.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use anyhow::{Result, anyhow, bail}; use serde_json::Value as JsonValue; -use tracing::{debug, info, warn}; use crate::import::{self, Imported}; use crate::option::{Kind, OptionSpec, Schema, from_text}; @@ -106,10 +105,14 @@ pub enum Overlay { } /// Puts `entry` for `name` into `layer`, which holds earlier sources, logging what it -/// replaces and dropping earlier values it can't be combined with. +/// replaces (with the feature `tracing`) and dropping earlier values it can't be combined +/// with. pub fn overlay(layer: &mut Layer, name: String, entry: Entry, how: Overlay, schema: &Schema) { + #[cfg(not(feature = "tracing"))] + let log = |_: &str, _: &str, _: &Entry| {}; + #[cfg(feature = "tracing")] let log = |message: &str, option: &str, previous: &Entry| match how { - Overlay::IncludeOverInclude => warn!( + Overlay::IncludeOverInclude => tracing::warn!( option, value = %entry.shown(schema.secret(&name)), from = %entry.origin, @@ -117,13 +120,13 @@ pub fn overlay(layer: &mut Layer, name: String, entry: Entry, how: Overlay, sche overridden_from = %previous.origin, "{message}" ), - Overlay::FileOverFile => debug!( + Overlay::FileOverFile => tracing::debug!( option, from = %entry.origin, overrides = %previous.origin, "{message}" ), - Overlay::ArgumentOverFile => info!( + Overlay::ArgumentOverFile => tracing::info!( option, value = %entry.shown(schema.secret(&name)), overrides = %previous.shown(schema.secret(option)), @@ -277,6 +280,7 @@ pub fn resolve_file_value( /// `T` read from the values `merged` sets, each option's by its name: those unset take /// `T`'s defaults. +#[cfg(feature = "serde")] pub fn read<T: serde::de::DeserializeOwned>(merged: &Layer) -> Result<T> { let object: serde_json::Map<String, JsonValue> = merged .iter() |
