more logging, and improved

This commit is contained in:
Simon Cruanes 2024-01-24 13:11:53 -05:00
parent df8b579d24
commit 51e1d1ece5
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -815,8 +815,9 @@ let add_route_server_sent_handler ?accept self route f =
let send_event = send_event
let close () = raise Exit_SSE
end in
try f req (module SSG : SERVER_SENT_GENERATOR)
with Exit_SSE -> IO.Output.close oc
(try f req (module SSG : SERVER_SENT_GENERATOR)
with Exit_SSE -> IO.Output.close oc);
Log.info (fun k -> k "closed SSE connection")
in
add_route_handler_ self ?accept ~meth:`GET route ~tr_req f
@ -1048,12 +1049,19 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
(* how to log the response to this query *)
let log_response (resp : Response.t) =
if not Log.dummy then
Log.info (fun k ->
if not Log.dummy then (
let msgf k =
let elapsed = B.get_time_s () -. req.start_time in
k "response to=%s path=%S code=%d time=%.3fs"
k
("response to=%s code=%d time=%.3fs path=%S" : _ format4)
(str_of_sockaddr client_addr)
req.path resp.code elapsed)
resp.code elapsed req.path
in
if Response_code.is_success resp.code then
Log.info msgf
else
Log.error msgf
)
in
(try