From c0530ee57d10a24fc12dca9217d9f8452260f2f9 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 5 Apr 2021 12:18:05 -0400 Subject: [PATCH] more debug --- src/blocking_IO.ml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/blocking_IO.ml b/src/blocking_IO.ml index 8b72da0d..be0c671d 100644 --- a/src/blocking_IO.ml +++ b/src/blocking_IO.ml @@ -32,12 +32,22 @@ let catch f g = try f() with e -> g e +let spf = Printf.sprintf + let rec read ic buf i len = if len>0 then ( let n = input ic buf i len in read ic buf (i+n) (len-n) ) -let read_line = input_line -let write oc b i len = output oc b i len; flush oc -let write_string oc s = output_string oc s; flush oc +let read_line ic = + let s = input_line ic in + !Jsonrpc2._log (fun () -> spf "read line: '%s'" s); + s + +let write oc b i len = + !Jsonrpc2._log (fun () -> spf "write '%s'[%d..%d]" (Bytes.unsafe_to_string b) i (i+len)); + output oc b i len; flush oc +let write_string oc s = + !Jsonrpc2._log (fun () -> spf "write-str '%s'" s); + output_string oc s; flush oc