Skip to content

Commit

Permalink
refactor(core-logger): organize log msg
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Nov 9, 2023
1 parent e2d0333 commit 67ea522
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions dar2oar_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rust-version = "1.60"
anyhow = { version = "1.0.75", features = ["backtrace"] }
async-walkdir = "0.2.0" # To traverse dir recursivly(Single thiread)
jwalk = "0.8.1" # To parallel traverse dir recursivly
log = "0.4.20" # Logger
nom = { version = "7.1.3", features = ["alloc"] } # Syntax
serde = { version = "1.0", features = ["derive"] } # Implement (De)Serializer
serde_json = "1.0" # Json converter
Expand All @@ -26,7 +25,7 @@ tokio = { version = "1.33.0", features = [
"rt",
] } # Async Executor
tokio-stream = "0.1.14" # Async next() method
tracing = "0.1.40"
tracing = "0.1.40" # Logger

[dev-dependencies]
criterion = { version = "0.5.1", features = [
Expand Down
5 changes: 2 additions & 3 deletions dar2oar_core/src/condition_parser/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ fn parse_condition(condition: Expression<'_>) -> Result<ConditionSet, ParseError
..Default::default()
}),
_ => {
log::debug!("Condition({fn_name}) has no explicit mapping.");

tracing::debug!("Condition({fn_name}) has no explicit mapping.");
ConditionSet::Condition(Condition {
condition: fn_name.into(),
negated,
condition: fn_name.to_string(),
..Default::default()
})
}
Expand Down
10 changes: 8 additions & 2 deletions dar2oar_core/src/condition_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use anyhow::bail;

pub fn parse_dar2oar(input: &str) -> anyhow::Result<Vec<ConditionSet>> {
let (_, dar_syn) = match parse_condition(input) {
Ok(syn) => syn,
Ok(syn) => {
tracing::debug!("Input => Parsed DAR:\n{:?}", syn);
syn
}
Err(err) => {
let err = match err {
nom::Err::Incomplete(_) => bail!("Error Incomplete"),
Expand All @@ -24,5 +27,8 @@ pub fn parse_dar2oar(input: &str) -> anyhow::Result<Vec<ConditionSet>> {
bail!(convert_error(input, err));
}
};
Ok(parse_conditions(dar_syn)?.try_into()?)

let oar = parse_conditions(dar_syn)?;
tracing::debug!("Parsed DAR => Serializable OAR:\n{:?}", oar);
Ok(oar.try_into()?)
}
2 changes: 1 addition & 1 deletion dar2oar_core/src/fs/path_changer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn parse_dar_path(path: impl AsRef<Path>, dar_dirname: Option<&str>) -> DarP
.or(Some({
path.parse::<i64>()
.is_err()
.then(|| log::debug!("Expected a priority dir name with numbers, but got \"{path}\" (perhaps a dir name as a memo)."));
.then(|| tracing::debug!("Expected a priority dir name with numbers, but got \"{path}\" (perhaps a dir name as a memo)."));
path.to_owned()
}))
})
Expand Down
3 changes: 2 additions & 1 deletion dar2oar_core/src/fs/sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ where
let mut dar_1st_namespace = None; // To need rename to hidden(For _1stperson)

let walk_len = WalkDir::new(&dar_dir).collect::<Vec<_>>().await.len(); // Lower performance cost when sender is None.
log::debug!("Dir & File Counts: {}", walk_len);
tracing::trace!("Send all dirs & files counts: {}", walk_len);
tokio::spawn(async_fn(walk_len));

let mut entries = WalkDir::new(dar_dir);
let mut idx = 0usize;
while let Some(entry) = entries.next().await {
tracing::trace!("Send Dir or file index: {}", idx);
tokio::spawn(async_fn(idx));
idx += 1;

Expand Down

0 comments on commit 67ea522

Please sign in to comment.