Print stdout
and stderr
as string
As the `stdout` as well as the `stderr` were printed as `Vec<u8>` we now convert it to a string.
This commit is contained in:
parent
0724da9ff5
commit
a130bdc125
1 changed files with 10 additions and 7 deletions
17
src/main.rs
17
src/main.rs
|
@ -15,7 +15,10 @@ use rocket::{fairing::AdHoc, get, http::Status, post, routes, Response, State};
|
|||
use rocket_contrib::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::{collections::HashMap, fs::File, io::BufReader, net::SocketAddr, process::Command};
|
||||
use std::{
|
||||
collections::HashMap, fs::File, io::BufReader, net::SocketAddr, process::Command,
|
||||
str::from_utf8,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct Config {
|
||||
|
@ -100,21 +103,21 @@ fn execute_hook(name: &str, hook: &Hook, data: &serde_json::Value) -> Result<()>
|
|||
info!("Execute `{}` from hook `{}`", command, name);
|
||||
|
||||
let command = command.split(' ').collect::<Vec<&str>>();
|
||||
|
||||
let exec_command = Command::new(&command[0]).args(&command[1..]).output()?;
|
||||
|
||||
info!(
|
||||
"Command `{}` exited with return code: {}",
|
||||
&command[0], &exec_command.status
|
||||
);
|
||||
debug!(
|
||||
"Output of command `{}` on stderr: {:?}",
|
||||
&command[0], &exec_command.stderr
|
||||
);
|
||||
trace!(
|
||||
"Output of command `{}` on stdout: {:?}",
|
||||
&command[0],
|
||||
&exec_command.stdout
|
||||
from_utf8(&exec_command.stdout)?
|
||||
);
|
||||
debug!(
|
||||
"Output of command `{}` on stderr: {:?}",
|
||||
&command[0],
|
||||
from_utf8(&exec_command.stderr)?
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue