mirror of
https://github.com/house-of-vanity/rexec.git
synced 2025-07-07 00:54:06 +00:00
Improved live logging
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -401,7 +401,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rexec"
|
name = "rexec"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"brace-expand",
|
"brace-expand",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rexec"
|
name = "rexec"
|
||||||
version = "1.5.0"
|
version = "1.5.1"
|
||||||
readme = "https://github.com/house-of-vanity/rexec#readme"
|
readme = "https://github.com/house-of-vanity/rexec#readme"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Parallel SSH executor"
|
description = "Parallel SSH executor"
|
||||||
|
23
src/main.rs
23
src/main.rs
@ -315,7 +315,7 @@ fn execute_ssh_command(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Function to handle output lines with proper block management
|
// Function to handle output lines with proper block management
|
||||||
let handle_output = |line: String, display_name: &str, code_only: bool| {
|
let handle_output = |line: String, display_name: &str, code_only: bool, is_stderr: bool| {
|
||||||
if !code_only {
|
if !code_only {
|
||||||
let mut current_block = CURRENT_BLOCK.lock().unwrap();
|
let mut current_block = CURRENT_BLOCK.lock().unwrap();
|
||||||
|
|
||||||
@ -338,8 +338,19 @@ fn execute_ssh_command(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the log line
|
// Print the log line with colored separator based on stream type
|
||||||
println!("│ {} │ {}", display_name.yellow(), line);
|
let separator = if is_stderr {
|
||||||
|
"│".red()
|
||||||
|
} else {
|
||||||
|
"│".green()
|
||||||
|
};
|
||||||
|
println!(
|
||||||
|
"{} {} {} {}",
|
||||||
|
separator,
|
||||||
|
display_name.yellow(),
|
||||||
|
separator,
|
||||||
|
line
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -353,7 +364,8 @@ fn execute_ssh_command(
|
|||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
match line {
|
match line {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
handle_output(line, &display_name_stdout, code_only_stdout);
|
handle_output(line, &display_name_stdout, code_only_stdout, false);
|
||||||
|
// false = stdout
|
||||||
}
|
}
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
}
|
}
|
||||||
@ -370,7 +382,8 @@ fn execute_ssh_command(
|
|||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
match line {
|
match line {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
handle_output(line, &display_name_stderr, code_only_stderr);
|
handle_output(line, &display_name_stderr, code_only_stderr, true);
|
||||||
|
// true = stderr
|
||||||
}
|
}
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user