mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
more logging, and improved
This commit is contained in:
parent
df8b579d24
commit
51e1d1ece5
1 changed files with 16 additions and 8 deletions
|
|
@ -815,8 +815,9 @@ let add_route_server_sent_handler ?accept self route f =
|
||||||
let send_event = send_event
|
let send_event = send_event
|
||||||
let close () = raise Exit_SSE
|
let close () = raise Exit_SSE
|
||||||
end in
|
end in
|
||||||
try f req (module SSG : SERVER_SENT_GENERATOR)
|
(try f req (module SSG : SERVER_SENT_GENERATOR)
|
||||||
with Exit_SSE -> IO.Output.close oc
|
with Exit_SSE -> IO.Output.close oc);
|
||||||
|
Log.info (fun k -> k "closed SSE connection")
|
||||||
in
|
in
|
||||||
add_route_handler_ self ?accept ~meth:`GET route ~tr_req f
|
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 *)
|
(* how to log the response to this query *)
|
||||||
let log_response (resp : Response.t) =
|
let log_response (resp : Response.t) =
|
||||||
if not Log.dummy then
|
if not Log.dummy then (
|
||||||
Log.info (fun k ->
|
let msgf k =
|
||||||
let elapsed = B.get_time_s () -. req.start_time in
|
let elapsed = B.get_time_s () -. req.start_time in
|
||||||
k "response to=%s path=%S code=%d time=%.3fs"
|
k
|
||||||
(str_of_sockaddr client_addr)
|
("response to=%s code=%d time=%.3fs path=%S" : _ format4)
|
||||||
req.path resp.code elapsed)
|
(str_of_sockaddr client_addr)
|
||||||
|
resp.code elapsed req.path
|
||||||
|
in
|
||||||
|
if Response_code.is_success resp.code then
|
||||||
|
Log.info msgf
|
||||||
|
else
|
||||||
|
Log.error msgf
|
||||||
|
)
|
||||||
in
|
in
|
||||||
|
|
||||||
(try
|
(try
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue