Skip to content

Commit

Permalink
feat: add quick_tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Jun 2, 2024
1 parent 2f950c8 commit 2d954ca
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 81 deletions.
120 changes: 98 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions dar2oar_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ rust-version = "1.60"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []
tracing = ["dep:tracing"]

[dependencies]
async-walkdir = "1.0.0" # To traverse dir recursivly(Single thiread)
compact_str = { version = "0.7.1", features = ["serde"] }
jwalk = "0.8.1" # To parallel traverse dir recursivly
nom = { version = "7.1.3", features = ["alloc"] } # Syntax
serde = { version = "1.0.202", features = ["derive"] } # Implement (De)Serializer
serde = { version = "1.0.202", features = [
"derive",
] } # Implement (De)Serializer
serde-untagged = "0.1.6"
serde_json = "1.0.117" # Json converter
thiserror = "1.0.61" # define errors type
Expand All @@ -30,7 +36,7 @@ tokio = { version = "1.37.0", features = [
"rt-multi-thread",
] } # Async Executor
tokio-stream = "0.1.15" # Async next() method
tracing = "0.1.40" # Logger
tracing = { version = "0.1.40", optional = true } # Logger

[dev-dependencies]
anyhow = { version = "1.0.86", features = ["backtrace"] }
Expand All @@ -40,10 +46,8 @@ criterion = { version = "0.5.1", features = [
"html_reports",
] }
pretty_assertions = "1.4.0"
quick_tracing = { version = "0.1.4", features = ["derive"] }
temp-dir = "0.1.13"
tracing-appender = "0.2.3"
tracing-subscriber = "0.3.18"


[[bench]]
name = "convert_n_thread"
Expand Down
4 changes: 4 additions & 0 deletions dar2oar_core/src/condition_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::error::{ConvertError, Result};
pub fn parse_dar2oar(input: &str) -> Result<Vec<ConditionSet>> {
let (remain, dar_syn) = match parse_condition(input) {
Ok(syn) => {
#[cfg(feature = "tracing")]
tracing::debug!("Input => Parsed DAR:\n{:#?}", syn);
syn
}
Expand All @@ -31,6 +32,7 @@ pub fn parse_dar2oar(input: &str) -> Result<Vec<ConditionSet>> {
nom::Err::Error(err) | nom::Err::Failure(err) => err,
};

#[cfg(feature = "tracing")]
tracing::trace!("Entered ConvertError::InvalidDarSyntax");
return Err(ConvertError::InvalidDarSyntax(convert_error(input, err)));
}
Expand All @@ -39,10 +41,12 @@ pub fn parse_dar2oar(input: &str) -> Result<Vec<ConditionSet>> {
match remain.is_empty() {
true => {
let oar = parse_conditions(dar_syn)?;
#[cfg(feature = "tracing")]
tracing::debug!("Parsed DAR => Serialized OAR:\n{:#?}", &oar);
Ok(oar.try_into()?)
}
false => {
#[cfg(feature = "tracing")]
tracing::trace!("Entered ConvertError::IncompleteParseDar");
Err(ConvertError::IncompleteParseDar(remain.into()))
}
Expand Down
Loading

0 comments on commit 2d954ca

Please sign in to comment.