Logging of RPCs

This commit is contained in:
Milo Davis 2017-08-25 11:21:27 +02:00 committed by Grégoire Henry
parent f2f4682606
commit f184be8ddc
2 changed files with 8 additions and 2 deletions

View File

@ -164,12 +164,14 @@ let preparse_args argv =
type cli_args = { type cli_args = {
block: Node_rpc_services.Blocks.block ; block: Node_rpc_services.Blocks.block ;
print_timings: bool ; print_timings: bool ;
log_requests: bool ;
force: bool ; force: bool ;
} }
let default_cli_args = { let default_cli_args = {
block = Client_commands.default_cfg.block ; block = Client_commands.default_cfg.block ;
print_timings = false ; print_timings = false ;
log_requests = false ;
force = false ; force = false ;
} }
@ -197,6 +199,9 @@ let parse_args usage dispatcher argv =
"-block", Arg.String (fun _ -> ( (* preparsed *) )), "-block", Arg.String (fun _ -> ( (* preparsed *) )),
"The block on which to apply contextual commands.\n\ "The block on which to apply contextual commands.\n\
default: " ^ Node_rpc_services.Blocks.to_string default_cli_args.block ; default: " ^ Node_rpc_services.Blocks.to_string default_cli_args.block ;
"-log-requests",
Arg.Unit (fun () -> parsed_args := { !parsed_args with log_requests = true }),
"If set, this flag causes all requests and responses to the node to be logged."
] in ] in
(* Command-line args which can be set in config file as well *) (* Command-line args which can be set in config file as well *)
let file_args = [ let file_args = [

View File

@ -78,8 +78,9 @@ let main () =
if parsed_args.print_timings then if parsed_args.print_timings then
{ rpc_config with { rpc_config with
logger = Client_rpcs.timings_logger Format.err_formatter } logger = Client_rpcs.timings_logger Format.err_formatter }
else else if parsed_args.log_requests
rpc_config then {rpc_config with logger = Client_rpcs.full_logger Format.err_formatter }
else rpc_config
in in
command (cctxt config rpc_config)) >>= function command (cctxt config rpc_config)) >>= function
| Ok () -> | Ok () ->