let log e =
let kv k v = Log.(brakets (s k % s " → " % v)) in
match e with
| `Unix_exec failure -> Log.(s "Unix-exec-error: " % s failure)
| `Non_zero (cmd, ex) -> Log.(s "Cmd " % sf "%S" cmd % s " returned " % i ex)
| `System (`Sleep time, `Exn e) ->
Log.(s "System error: sleep " % f time % s " failed: " % exn e)
| `Timeout t -> Log.(s "Timed-out " % parens (f t % s " sec"))
| `Execution exec ->
Log.(
s "Process execution failed: "
% kv "Host" (s exec#host)
% kv "Message" (s exec#message)
% kv "Stdout" (option s exec#stdout)
% kv "Stderr" (option s exec#stderr))
| `Ssh_failure (`Wrong_log log, msg) ->
Log.(s "SSH failed parsing log:" % s msg % kv "Log" (sf "%S" log))
| `Ssh_failure (`Wrong_status exit_code, msg) ->
Log.(s "SSH failed:" % s msg
% kv "Exit code" (Ketrew_unix_process.Exit_code.to_log exit_code))