Skip to content

Commit

Permalink
Remove old dependency from Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 17, 2024
1 parent 4fba22d commit 110d2f4
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 42 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.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ clap = { version = "=4.4.0", features = ["derive"] }
env_logger = "0.11.3"
lazy_static = "1.4.0"
log = "0.4.21"
once_cell = "1.19.0"
regex = "1.10.3"
rstest = "0.19.0"
rstest_reuse = "0.6.0"
37 changes: 1 addition & 36 deletions src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
use crate::colors::*;
use crate::print::*;
use crate::Cli;
use env_logger::Builder;
use log::Level;
use log::Level::{Debug, Error, Info, Trace, Warn};
use log::Level::{Error, Info, Warn};
use log::LevelFilter;
use once_cell::sync::Lazy;
use std::collections::HashSet;
use std::io::Write;
use std::sync::Mutex;

pub static LOGS: Lazy<Mutex<HashSet<Log>>> =
Lazy::new(|| Mutex::new(HashSet::new()));

#[derive(Eq, Hash, PartialEq, Clone)]
pub struct Log {
level: Level,
linum: usize,
message: String,
}

fn get_log_style(log_level: Level) -> String {
match log_level {
Expand Down Expand Up @@ -51,24 +37,3 @@ pub fn init_logger(args: &Cli) {
})
.init();
}

pub fn print_logs(filename: &str) {
let mut logs: Vec<Log> = vec![];
for log in LOGS.lock().unwrap().iter() {
logs.push(log.clone());
}
logs.sort_by_key(|l| l.linum);

if !logs.is_empty() {
print_filename(filename);
}
for log in logs {
match log.level {
Error => log::error!("{}", log.message),
Warn => log::warn!("{}", log.message),
Info => log::info!("{}", log.message),
Debug => log::debug!("{}", log.message),
Trace => log::trace!("{}", log.message),
}
}
}
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ fn main() {
print_script_name();

for filename in &args.filenames {
LOGS.lock().unwrap().clear();

if args.verbose {
print_filename(filename);
}
Expand All @@ -60,7 +58,5 @@ fn main() {
} else {
write_file(filename, &new_file);
}

print_logs(filename);
}
}

0 comments on commit 110d2f4

Please sign in to comment.