mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-18 23:08:00 +00:00
miragesdk: be a bit less verbose in debug mode
It's not very interesting to see the forwarded stdout/stderr messages as they will end-up being printed anyway. Signed-off-by: Thomas Gazagnaire <thomas@gazagnaire.org>
This commit is contained in:
parent
b18d50b5e4
commit
2b0009ee06
@ -35,7 +35,7 @@ let pp ppf (Flow (name, _, _)) = Fmt.string ppf name
|
||||
|
||||
type t = flow
|
||||
|
||||
let forward ~src ~dst =
|
||||
let forward ?(verbose=false) ~src ~dst =
|
||||
let rec loop () =
|
||||
read src >>= function
|
||||
| Ok `Eof ->
|
||||
@ -45,8 +45,12 @@ let forward ~src ~dst =
|
||||
Log.err (fun l -> l "forward[%a => %a] %a" pp src pp dst pp_error e);
|
||||
Lwt.return_unit
|
||||
| Ok (`Data buf) ->
|
||||
Log.debug (fun l -> l "forward[%a => %a] %d bytes"
|
||||
pp src pp dst @@ Cstruct.len buf);
|
||||
Log.debug (fun l ->
|
||||
let payload =
|
||||
if verbose then Fmt.strf "[%S]" @@ Cstruct.to_string buf
|
||||
else Fmt.strf "%d bytes" (Cstruct.len buf)
|
||||
in
|
||||
l "forward[%a => %a] %s" pp src pp dst payload);
|
||||
write dst buf >>= function
|
||||
| Ok () -> loop ()
|
||||
| Error e ->
|
||||
@ -56,8 +60,8 @@ let forward ~src ~dst =
|
||||
in
|
||||
loop ()
|
||||
|
||||
let proxy f1 f2 =
|
||||
let proxy ?verbose f1 f2 =
|
||||
Lwt.join [
|
||||
forward ~src:f1 ~dst:f2;
|
||||
forward ~src:f2 ~dst:f1;
|
||||
forward ?verbose ~src:f1 ~dst:f2;
|
||||
forward ?verbose ~src:f2 ~dst:f1;
|
||||
]
|
||||
|
@ -12,10 +12,14 @@ val create: (module Mirage_flow_lwt.S with type flow = 'a) -> 'a -> string -> fl
|
||||
val pp: flow Fmt.t
|
||||
(** [pp] is the pretty-printer for IO flows. *)
|
||||
|
||||
val forward: src:t -> dst:t -> unit Lwt.t
|
||||
(** [forward ~src ~dst] forwards writes from [src] to [dst]. Block
|
||||
until either [src] or [dst] is closed. *)
|
||||
val forward: ?verbose:bool -> src:t -> dst:t -> unit Lwt.t
|
||||
(** [forward ?verbose ~src ~dst] forwards writes from [src] to
|
||||
[dst]. Block until either [src] or [dst] is closed. If [verbose]
|
||||
is set (by default it is not), show the raw flow in debug mode,
|
||||
otherwise just show the lenght. *)
|
||||
|
||||
val proxy: t -> t -> unit Lwt.t
|
||||
(** [proxy x y] is the same as [forward x y <*> forward y x]. Block
|
||||
until both flows are closed. *)
|
||||
val proxy: ?verbose:bool -> t -> t -> unit Lwt.t
|
||||
(** [proxy ?verbose x y] is the same as [forward x y <*> forward y
|
||||
x]. Block until both flows are closed. If [verbose] is set (by
|
||||
default it is not), show the raw flow in debug mode, otherwise
|
||||
just show the lenght. *)
|
||||
|
@ -291,11 +291,11 @@ let exec_and_forward ?(handlers=block_for_ever) ~pid ~cmd ~net ~ctl t =
|
||||
Lwt.pick ([
|
||||
wait ();
|
||||
(* data *)
|
||||
IO.proxy net priv_net;
|
||||
IO.proxy ~verbose:true net priv_net;
|
||||
|
||||
(* redirect the calf stdout to the shim stdout *)
|
||||
IO.forward ~src:priv_stdout ~dst:Fd.(flow stdout);
|
||||
IO.forward ~src:priv_stderr ~dst:Fd.(flow stderr);
|
||||
IO.forward ~verbose:false ~src:priv_stdout ~dst:Fd.(flow stdout);
|
||||
IO.forward ~verbose:false ~src:priv_stderr ~dst:Fd.(flow stderr);
|
||||
(* TODO: Init.Fd.forward ~src:Init.Pipe.(priv metrics)
|
||||
~dst:Init.Fd.metric; *)
|
||||
ctl priv_ctl;
|
||||
|
Loading…
Reference in New Issue
Block a user