mirror of
https://github.com/house-of-vanity/rexec.git
synced 2025-07-06 08:34:07 +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]]
|
||||
name = "rexec"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"brace-expand",
|
||||
"clap",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rexec"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
readme = "https://github.com/house-of-vanity/rexec#readme"
|
||||
edition = "2021"
|
||||
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
|
||||
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 {
|
||||
let mut current_block = CURRENT_BLOCK.lock().unwrap();
|
||||
|
||||
@ -338,8 +338,19 @@ fn execute_ssh_command(
|
||||
}
|
||||
}
|
||||
|
||||
// Print the log line
|
||||
println!("│ {} │ {}", display_name.yellow(), line);
|
||||
// Print the log line with colored separator based on stream type
|
||||
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() {
|
||||
match 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,
|
||||
}
|
||||
@ -370,7 +382,8 @@ fn execute_ssh_command(
|
||||
for line in reader.lines() {
|
||||
match 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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user