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:
finga 2021-03-22 11:12:45 +01:00
parent 0724da9ff5
commit a130bdc125

View file

@ -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)?
);
}