Skip to content

Commit

Permalink
[sniff] Change debug -> info in some places
Browse files Browse the repository at this point in the history
Signed-off-by: Shinyzenith <[email protected]>
  • Loading branch information
Shinyzenith committed Sep 19, 2022
1 parent b9ceeb7 commit 1447562
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 81 deletions.
31 changes: 0 additions & 31 deletions sniff.1.scd

This file was deleted.

42 changes: 0 additions & 42 deletions sniff.5.scd

This file was deleted.

20 changes: 12 additions & 8 deletions src/sniff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Ignore {
fn main() {
let mut last_run: Instant = Instant::now();

env::set_var("RUST_LOG", "sniff=warn");
env::set_var("RUST_LOG", "sniff=info");
let mut args = args();
if let Some(arg) = args.nth(1) {
match arg.as_str() {
Expand Down Expand Up @@ -87,7 +87,9 @@ fn fetch_sniff_config_file() -> String {
Path::new(&val).join("sniff/sniff.json")
}
Err(_) => {
log::error!("XDG_CONFIG_HOME has not been set.");
log::error!(
"XDG_CONFIG_HOME has not been set. Falling back to ~/.config/sniff/sniff.json"
);
Path::new("~/.config/sniff/sniff.json").to_path_buf()
}
};
Expand All @@ -107,7 +109,7 @@ fn run_system_command(command: &str) {
log::error!("Failed to execute {}", command);
log::error!("Error, {}", e);
} else {
log::debug!("Ran: {:#?}", command);
log::info!("Ran: {:#?}", command);
}
}

Expand All @@ -117,6 +119,12 @@ fn check_and_run(
ignore_list: Ignore,
last_run: &mut Instant,
) {
// Cooldown check.
if Instant::now().duration_since(*last_run).as_millis() < ignore_list.sniff_cooldown {
log::debug!("In cooldown.");
return;
}

// First the file check.
for ignore_file in ignore_list.sniff_ignore_file {
if ignore_file[..] == file_name[file_name.rfind('/').unwrap() + 1..] {
Expand All @@ -136,11 +144,6 @@ fn check_and_run(
}
}

// Cooldown check.
if Instant::now().duration_since(*last_run).as_millis() < ignore_list.sniff_cooldown {
log::debug!("In cooldown.");
return;
}
*last_run = Instant::now();

match json {
Expand All @@ -157,6 +160,7 @@ fn check_and_run(
for command in arr {
match command {
serde_json::Value::String(command) => {
log::info!("Running build scripts for: {:#?}", file_name);
run_system_command(command);
}
_ => {
Expand Down

0 comments on commit 1447562

Please sign in to comment.