Skip to content

Commit

Permalink
Make debug logs conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood committed Apr 11, 2024
1 parent 9769f13 commit 29ff8b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/eval/StateIPCClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ let ipcclient_exn_wrapper thunk =
fail0 ~kind:("StateIPCClient: Unix error: " ^ s1 ^ s2) ?inst:None
| e ->
let e = Exn.to_string e in
print_endline (Printf.sprintf "error making JSON-RPC call: %s" e);
DebugMessage.plog (Printf.sprintf "error making JSON-RPC call: %s" e);
fail0 ~kind:"StateIPCClient: Unexpected error making JSON-RPC call"
?inst:None

let http_rpc ~socket_addr (call : Rpc.call) : Rpc.response M.t =
let msg_buf = Jsonrpc.string_of_call ~version:Jsonrpc.V2 call in
print_endline (Printf.sprintf "Sending: %s\n" msg_buf);
DebugMessage.plog (Printf.sprintf "Sending: %s\n" msg_buf);
let exception Http_error of string in
let response =
match Ezcurl.post ~headers:["content-type", "application/json"] ~content:(`String msg_buf) ~params:[] ~url:socket_addr () with
| Ok response -> response
| Error (_, err) -> (
print_endline (Printf.sprintf "error calling RPC: %s" err);
DebugMessage.plog (Printf.sprintf "error calling RPC: %s" err);
raise (Http_error (Printf.sprintf "error calling RPC: %s" err))
)
in

let response = if response.code = 200 then response.body else (
print_endline (Printf.sprintf "error response from RPC: code: %d, body: %s" response.code response.body);
DebugMessage.plog (Printf.sprintf "error response from RPC: code: %d, body: %s" response.code response.body);
raise (Http_error "error response from RPC")
)
in

print_endline (Printf.sprintf "Response: %s\n" response);
DebugMessage.plog (Printf.sprintf "Response: %s\n" response);
M.return @@ Jsonrpc.response_of_string response

(* Encode a literal into bytes, opaque to the backend storage. *)
Expand Down
2 changes: 1 addition & 1 deletion src/runners/scilla_server_http.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let run_handler req =
let res =
try M.run (rpc req)
with e ->
print_endline (Exn.to_string e);
DebugMessage.plog (Exn.to_string e);
Rpc.failure
(RPCError.rpc_of_t
RPCError.
Expand Down

0 comments on commit 29ff8b9

Please sign in to comment.