diff --git a/src/main.rs b/src/main.rs index d39ddbd..33ae35b 100644 --- a/src/main.rs +++ b/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::>(); - 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)? ); }