Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarzik committed Feb 18, 2024
1 parent 0d3c954 commit 4746c13
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 14 deletions.
93 changes: 87 additions & 6 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ description = "pcgtools: tools for reading PCgen PCC and LST data files"

[dependencies]
clap = { version = "4", features = ["derive"] }
env_logger = "0.11"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
19 changes: 11 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// SPDX-License-Identifier: MIT

extern crate clap;
extern crate log;

use clap::Parser;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -201,25 +202,25 @@ impl Pcc {
match self.aliases.get(&ident) {
None => {}
Some(alias) => {
println!("ALIAS MATCH: {} => {}", ident, alias);
log::debug!("ALIAS MATCH: {} => {}", ident, alias);
ident = alias.clone();
}
}

println!("ID={}, is_mod={}", ident, is_mod);
log::debug!("ID={}, is_mod={}", ident, is_mod);

// gather key=value attribs into a list
let mut attribs: Vec<(String, String)> = Vec::new();
for token in &tokens {
match token.split_once(':') {
None => {
if !token.trim().is_empty() {
println!("\t{}", token);
log::debug!("\t{}", token);
attribs.push((token.to_string(), String::from("")));
}
}
Some((akey, aval)) => {
println!("\t{}={}", akey, aval);
log::debug!("\t{}={}", akey, aval);
attribs.push((akey.to_string(), aval.to_string()));
}
}
Expand All @@ -229,12 +230,12 @@ impl Pcc {
for (key, val) in &attribs {
match key.as_str() {
"ABB" => {
println!("ALIAS: {}={}", val, ident);
log::debug!("ALIAS: {}={}", val, ident);
self.aliases.insert(val.to_string(), ident.clone());
}

"KEY" => {
println!("KEY: {}={}", val, ident);
log::debug!("KEY: {}={}", val, ident);
ident = val.to_string();
}

Expand Down Expand Up @@ -297,7 +298,7 @@ impl Pcc {
}
}

println!("Pcc.read_lst({}, {}, \"{}\")", pcc_tag, fpath, lstopts);
log::debug!("Pcc.read_lst({}, {}, \"{}\")", pcc_tag, fpath, lstopts);

let mut datum;

Expand Down Expand Up @@ -436,7 +437,7 @@ impl Pcc {

let basedir = dir_from_path(&fpath).unwrap();

println!("Pcc.read({})", fpath);
log::debug!("Pcc.read({})", fpath);

let file = File::open(fpath)?;
let rdr = BufReader::new(file);
Expand All @@ -463,6 +464,8 @@ impl Pcc {
}

fn main() {
env_logger::builder().format_timestamp(None).init();

// parse command line options
let args = Args::parse();

Expand Down

0 comments on commit 4746c13

Please sign in to comment.