diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-24 11:38:08 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-24 11:46:52 +0200 |
commit | 84a07a5b77575a981c86b7e9a3e697428d4a94d2 (patch) | |
tree | f3c9d3a89e605fa140748c34544473e9a7556d92 /src/bindings.rs | |
parent | bcc64e41ca47b1578b3d697d02cdff0ca1e0daa3 (diff) | |
download | subplot-84a07a5b77575a981c86b7e9a3e697428d4a94d2.tar.gz |
feat! change logging to use log/env_logger instead of tracing
We don't use async in Subplot, and the mental overhead of learning
tracing and the code overhead to add support for logging custom
values (implementing the Value trait for Subplot internal types) does
not seem worthwhile.
Sponsored-by: author
Diffstat (limited to 'src/bindings.rs')
-rw-r--r-- | src/bindings.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/bindings.rs b/src/bindings.rs index 2d5f062..0837553 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -16,8 +16,8 @@ use std::str::FromStr; use std::sync::Arc; use lazy_static::lazy_static; +use log::trace; use regex::{escape, Regex, RegexBuilder}; -use tracing::{event, instrument, Level}; #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] @@ -462,7 +462,6 @@ impl Bindings { } /// Add bindings from a YAML string - #[instrument(level = "trace", skip(self, yaml))] pub fn add_from_yaml(&mut self, yaml: &str) -> Result<()> { let bindings: Vec<ParsedBindingWrapper> = serde_yaml::from_str(yaml)?; for wrapper in bindings { @@ -500,14 +499,13 @@ impl Bindings { } /// Add bindings from a file. - #[instrument(level = "trace", skip(self))] pub fn add_from_file<P>(&mut self, filename: P, template: Option<&str>) -> Result<()> where P: AsRef<Path> + Debug, { let yaml = resource::read_as_string(filename.as_ref(), template) .map_err(|e| SubplotError::BindingsFileNotFound(filename.as_ref().into(), e))?; - event!(Level::TRACE, "Loaded file content"); + trace!("Loaded file content"); self.add_from_yaml(&yaml).map_err(|e| { SubplotError::BindingFileParseError(filename.as_ref().to_owned(), Box::new(e)) })?; @@ -524,7 +522,6 @@ impl Bindings { } } -#[instrument(level = "trace", skip(parsed))] fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding> { let given: i32 = parsed.given.is_some().into(); let when: i32 = parsed.when.is_some().into(); @@ -560,16 +557,10 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding> { regex_from_simple_pattern(pattern, parsed.regex.is_some(), &mut types)? }; - event!( - Level::TRACE, - ?kind, - ?pattern, - ?types, - "Successfully acquired binding" - ); + trace!("Successfully acquired binding"); let mut ret = Binding::new(kind, &pattern, parsed.case_sensitive, types)?; - event!(Level::TRACE, "Binding parsed OK"); + trace!("Binding parsed OK"); for (template, pimpl) in &parsed.impls { ret.add_impl(template, &pimpl.function, pimpl.cleanup.as_deref()); } |