Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make debug logs conditional #1250

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading