+static void
+jsonrpc_log_msg(const struct jsonrpc *rpc, const char *title,
+ const struct jsonrpc_msg *msg)
+{
+ if (VLOG_IS_DBG_ENABLED()) {
+ struct ds s = DS_EMPTY_INITIALIZER;
+ if (msg->method) {
+ ds_put_format(&s, ", method=\"%s\"", msg->method);
+ }
+ if (msg->params) {
+ ds_put_cstr(&s, ", params=");
+ ds_put_and_free_cstr(&s, json_to_string(msg->params, 0));
+ }
+ if (msg->result) {
+ ds_put_cstr(&s, ", result=");
+ ds_put_and_free_cstr(&s, json_to_string(msg->result, 0));
+ }
+ if (msg->error) {
+ ds_put_cstr(&s, ", error=");
+ ds_put_and_free_cstr(&s, json_to_string(msg->error, 0));
+ }
+ if (msg->id) {
+ ds_put_cstr(&s, ", id=");
+ ds_put_and_free_cstr(&s, json_to_string(msg->id, 0));
+ }
+ VLOG_DBG("%s: %s %s%s", rpc->name, title,
+ jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s));
+ ds_destroy(&s);
+ }
+}
+