Skip to content

Commit f97b0ad

Browse files
committed
feat: add debug and error logging to run_command function
- Add tracing::debug! macro to log stdout output at debug level - Add tracing::error! macro to always log stderr output when not empty - Improve observability by logging command outputs with structured context - Enhance error visibility while maintaining debug-level stdout logging
1 parent 3958ac5 commit f97b0ad

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/shared/executor.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,28 @@ impl CommandExecutor {
107107
source,
108108
})?;
109109

110+
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
111+
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
112+
113+
// Always log stderr if it's not empty
114+
if !stderr.trim().is_empty() {
115+
tracing::error!(
116+
operation = "command_execution",
117+
command = %command_display,
118+
stderr = %stderr,
119+
"Command produced stderr output"
120+
);
121+
}
122+
123+
// Log stdout at debug level
124+
tracing::debug!(
125+
operation = "command_execution",
126+
command = %command_display,
127+
stdout = %stdout,
128+
"Command output"
129+
);
130+
110131
if !output.status.success() {
111-
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
112-
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
113132
let exit_code = output
114133
.status
115134
.code()
@@ -123,7 +142,7 @@ impl CommandExecutor {
123142
});
124143
}
125144

126-
Ok(String::from_utf8_lossy(&output.stdout).to_string())
145+
Ok(stdout)
127146
}
128147
}
129148

0 commit comments

Comments
 (0)