chore(config): add trace logs

This commit is contained in:
Harsh Shandilya 2022-07-13 13:46:58 +05:30
parent 3846e67e4b
commit a8b4b579a7
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -2,6 +2,7 @@ use std::str::FromStr;
use regex::Regex; use regex::Regex;
use serde_derive::Deserialize; use serde_derive::Deserialize;
use tracing::trace;
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Replacements<'config> { pub struct Replacements<'config> {
@ -67,6 +68,7 @@ pub trait Act {
impl Match for Matcher<'_> { impl Match for Matcher<'_> {
fn check_match(&self, string: &str) -> bool { fn check_match(&self, string: &str) -> bool {
trace!(?self, ?string, "Checking for match");
match self { match self {
Matcher::StartsWith { prefix } => string.starts_with(prefix), Matcher::StartsWith { prefix } => string.starts_with(prefix),
Matcher::EndsWith { suffix } => string.ends_with(suffix), Matcher::EndsWith { suffix } => string.ends_with(suffix),
@ -96,6 +98,7 @@ impl Match for MatcherType<'_> {
impl Act for Action<'_> { impl Act for Action<'_> {
fn apply_action(&self, input: &str) -> String { fn apply_action(&self, input: &str) -> String {
trace!(?self, ?input, "Applying action");
match self { match self {
Action::Replace { from, to } => input.replace(from, to), Action::Replace { from, to } => input.replace(from, to),
Action::Prefix { prefix } => format!("{}{}", prefix, input), Action::Prefix { prefix } => format!("{}{}", prefix, input),