Commit de0e2297 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

log_rpc: move log_enable_timestamps definition



This RPC was originally put into the app_rpc library,
but the log_rpc library is a better home for it, since
other log-related RPCs are already there.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I7ba5ac6cdeb57fb4219244690590c8fabbc3f59a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4361


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent ee17068b
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -337,4 +337,35 @@ rpc_log_get_flags(struct spdk_jsonrpc_request *request,
SPDK_RPC_REGISTER("log_get_flags", rpc_log_get_flags, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(log_get_flags, get_log_flags)

struct rpc_log_enable_timestamps {
	bool enabled;
};

static const struct spdk_json_object_decoder rpc_log_enable_timestamps_decoders[] = {
	{"enabled", offsetof(struct rpc_log_enable_timestamps, enabled), spdk_json_decode_bool},
};

static void
rpc_log_enable_timestamps(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
{
	struct rpc_log_enable_timestamps req = {};
	struct spdk_json_write_ctx *w;

	if (spdk_json_decode_object(params, rpc_log_enable_timestamps_decoders,
				    SPDK_COUNTOF(rpc_log_enable_timestamps_decoders),
				    &req)) {
		SPDK_ERRLOG("spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "spdk_json_decode_object failed");
		return;
	}

	spdk_log_enable_timestamps(req.enabled);

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_bool(w, true);
	spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("log_enable_timestamps", rpc_log_enable_timestamps, SPDK_RPC_RUNTIME)
SPDK_LOG_REGISTER_COMPONENT("log_rpc", SPDK_LOG_LOG_RPC)
+0 −32
Original line number Diff line number Diff line
@@ -540,36 +540,4 @@ err:
	free(ctx);
}
SPDK_RPC_REGISTER("thread_set_cpumask", rpc_thread_set_cpumask, SPDK_RPC_RUNTIME)

struct rpc_log_enable_timestamps {
	bool enabled;
};

static const struct spdk_json_object_decoder rpc_log_enable_timestamps_decoders[] = {
	{"enabled", offsetof(struct rpc_log_enable_timestamps, enabled), spdk_json_decode_bool},
};

static void
rpc_log_enable_timestamps(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
{
	struct rpc_log_enable_timestamps req = {};
	struct spdk_json_write_ctx *w;

	if (spdk_json_decode_object(params, rpc_log_enable_timestamps_decoders,
				    SPDK_COUNTOF(rpc_log_enable_timestamps_decoders),
				    &req)) {
		SPDK_ERRLOG("spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "spdk_json_decode_object failed");
		return;
	}

	spdk_log_enable_timestamps(req.enabled);

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_bool(w, true);
	spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("log_enable_timestamps", rpc_log_enable_timestamps, SPDK_RPC_RUNTIME)
SPDK_LOG_REGISTER_COMPONENT("APP_RPC", SPDK_LOG_APP_RPC)