Commit d267d0e8 authored by Vitaliy Mysak's avatar Vitaliy Mysak Committed by Tomasz Zawadzki
Browse files

lib/log: add RPC to toggle timestamps



Allow toggling log timestamps on and off by adding new RPC call.

Change-Id: I34c84bf89fae352ade266fbf7fd20594ff67bced
Signed-off-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2024


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent cf99beb8
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -708,6 +708,41 @@ Example response:
}
~~~

## log_enable_timestamps {#rpc_log_enable_timestamps}

Enable or disable timestamps.

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
enabled                 | Required | boolean     | on or off

### Example

Example request:

~~~
{
  "jsonrpc": "2.0",
  "method": "log_enable_timestamps",
  "id": 1,
  "params": {
    "enabled": true
  }
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

## thread_get_pollers {#rpc_thread_get_pollers}

Retrieve current pollers of all the threads.
+5 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ void spdk_log_open(logfunc *logf);
 */
void spdk_log_close(void);

/**
 * Enable or disable timestamps
 */
void spdk_log_enable_timestamps(bool value);

enum spdk_log_level {
	/** All messages will be suppressed. */
	SPDK_LOG_DISABLED = -1,
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 3
SO_MINOR := 0
SO_MINOR := 1
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

C_SRCS = log.c log_flags.c
+12 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ static const char *const spdk_level_names[] = {
#define MAX_TMPBUF 1024

static logfunc *g_log = NULL;
static bool g_log_timestamps = true;

void
spdk_log_open(logfunc *logf)
@@ -65,6 +66,12 @@ spdk_log_close(void)
	}
}

void
spdk_log_enable_timestamps(bool value)
{
	g_log_timestamps = value;
}

static void
get_timestamp_prefix(char *buf, int buf_size)
{
@@ -73,6 +80,11 @@ get_timestamp_prefix(char *buf, int buf_size)
	struct timespec ts;
	long usec;

	if (!g_log_timestamps) {
		buf[0] = '\0';
		return;
	}

	clock_gettime(CLOCK_REALTIME, &ts);
	info = localtime(&ts.tv_sec);
	usec = ts.tv_nsec / 1000;
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
	spdk_log_set_flag;
	spdk_log_clear_flag;
	spdk_log_usage;
	spdk_log_enable_timestamps;

	# functions used by other SPDK libraries
	spdk_log_register_flag;
Loading