Client: improve printing of logged requests

This commit is contained in:
Milo Davis 2018-05-10 14:06:28 -07:00 committed by Grégoire Henry
parent b48ba96106
commit f0612a96ea

View File

@ -98,11 +98,11 @@ module Make (Encoding : Resto.ENCODING) = struct
let id = !cpt in let id = !cpt in
let uri = Uri.to_string uri in let uri = Uri.to_string uri in
incr cpt ; incr cpt ;
Format.fprintf ppf "@[<2>>>>>%d: %s@,%a@]@." id uri (media.pp enc) body ; Format.fprintf ppf "@[<v 2>>>>>%d: %s@,%a@]@." id uri (media.pp enc) body ;
Lwt.return (id, uri) Lwt.return (id, uri)
let log_response (id, _uri) ?(media = faked_media) enc code body = let log_response (id, _uri) ?(media = faked_media) enc code body =
Lazy.force body >>= fun body -> Lazy.force body >>= fun body ->
Format.fprintf ppf "@[<2><<<<%d: %s@,%a@]@." Format.fprintf ppf "@[<v 2><<<<%d: %s@,%a@]@."
id (Cohttp.Code.string_of_status code) (media.pp enc) body ; id (Cohttp.Code.string_of_status code) (media.pp enc) body ;
Lwt.return_unit Lwt.return_unit
end : LOGGER) end : LOGGER)