From ad474e95bbc8a0c8569151352399f880857867cf Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 13 Jun 2017 11:48:28 -0700 Subject: [PATCH] log: Remove configurable log facility Always use "Local7" internally. We want the log API to be generic instead of syslog specific. Change-Id: I021f719e90c236f123fa1cadebc0c199b87ba077 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/365295 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- app/iscsi_tgt/iscsi_tgt.c | 7 +-- app/nvmf_tgt/nvmf_main.c | 7 +-- app/vhost/vhost.c | 6 +- etc/spdk/iscsi.conf.in | 3 - etc/spdk/nvmf.conf.in | 3 - etc/spdk/rocksdb.conf.in | 3 - etc/spdk/vhost.conf.in | 3 - include/spdk/event.h | 1 - include/spdk/log.h | 3 - lib/event/app.c | 48 +-------------- lib/log/log.c | 74 +----------------------- test/iscsi_tgt/calsoft/iscsi.conf | 1 - test/iscsi_tgt/ext4test/iscsi.conf.in | 1 - test/iscsi_tgt/filesystem/iscsi.conf | 1 - test/iscsi_tgt/fio/iscsi.conf.in | 1 - test/iscsi_tgt/idle_migration/iscsi.conf | 1 - test/iscsi_tgt/ip_migration/iscsi.conf | 1 - test/iscsi_tgt/nvme_remote/iscsi.conf | 1 - test/iscsi_tgt/rbd/iscsi.conf | 1 - test/iscsi_tgt/reset/iscsi.conf | 1 - test/iscsi_tgt/rpc_config/iscsi.conf | 1 - test/nvmf/nvmf.conf | 1 - test/unit/lib/log/log.c/log_ut.c | 19 ------ test/vhost/fiotest/vhost.conf.in | 1 - test/vhost/integrity/vhost.conf.in | 1 - 25 files changed, 5 insertions(+), 185 deletions(-) diff --git a/app/iscsi_tgt/iscsi_tgt.c b/app/iscsi_tgt/iscsi_tgt.c index fe4adae2e..71af79a4d 100644 --- a/app/iscsi_tgt/iscsi_tgt.c +++ b/app/iscsi_tgt/iscsi_tgt.c @@ -67,8 +67,6 @@ usage(char *executable_name) printf(" -e mask tracepoint group mask for spdk trace buffers (default 0x0)\n"); printf(" -m mask core mask for DPDK\n"); printf(" -i shared memory ID (optional)\n"); - printf(" -l facility use specific syslog facility (default %s)\n", - opts.log_facility); printf(" -n channel number of memory channels used for DPDK\n"); printf(" -p core master (primary) core for DPDK\n"); printf(" -s size memory size in MB for DPDK\n"); @@ -103,7 +101,7 @@ main(int argc, char **argv) opts.config_file = SPDK_ISCSI_DEFAULT_CONFIG; opts.name = "iscsi"; - while ((ch = getopt(argc, argv, "bc:de:i:l:m:n:p:qs:t:H")) != -1) { + while ((ch = getopt(argc, argv, "bc:de:i:m:n:p:qs:t:H")) != -1) { switch (ch) { case 'd': opts.enable_coredump = false; @@ -114,9 +112,6 @@ main(int argc, char **argv) case 'i': opts.shm_id = atoi(optarg); break; - case 'l': - opts.log_facility = optarg; - break; case 't': rc = spdk_log_set_trace_flag(optarg); if (rc < 0) { diff --git a/app/nvmf_tgt/nvmf_main.c b/app/nvmf_tgt/nvmf_main.c index 1cea02f09..80593b321 100644 --- a/app/nvmf_tgt/nvmf_main.c +++ b/app/nvmf_tgt/nvmf_main.c @@ -54,8 +54,6 @@ usage(void) printf(" -e mask - tracepoint group mask for spdk trace buffers (default 0x0)\n"); printf(" -m mask - core mask for DPDK\n"); printf(" -i shared memory ID (optional)\n"); - printf(" -l facility - use specific syslog facility (default %s)\n", - opts.log_facility); printf(" -n channel number of memory channels used for DPDK\n"); printf(" -p core master (primary) core for DPDK\n"); printf(" -s size memory size in MB for DPDK\n"); @@ -82,7 +80,7 @@ main(int argc, char **argv) opts.config_file = SPDK_NVMF_DEFAULT_CONFIG; opts.max_delay_us = 1000; /* 1 ms */ - while ((ch = getopt(argc, argv, "c:de:i:l:m:n:p:qs:t:DH")) != -1) { + while ((ch = getopt(argc, argv, "c:de:i:m:n:p:qs:t:DH")) != -1) { switch (ch) { case 'd': opts.enable_coredump = false; @@ -93,9 +91,6 @@ main(int argc, char **argv) case 'i': opts.shm_id = atoi(optarg); break; - case 'l': - opts.log_facility = optarg; - break; case 't': rc = spdk_log_set_trace_flag(optarg); if (rc < 0) { diff --git a/app/vhost/vhost.c b/app/vhost/vhost.c index d1391e583..aa07af7ff 100644 --- a/app/vhost/vhost.c +++ b/app/vhost/vhost.c @@ -65,7 +65,6 @@ usage(char *executable_name) printf(" -c config config file (default: %s)\n", defaults.config_file); printf(" -e mask tracepoint group mask for spdk trace buffers (default: 0x0)\n"); printf(" -m mask reactor core mask (default: 0x1)\n"); - printf(" -l facility use specific syslog facility (default: %s)\n", defaults.log_facility); printf(" -n channel number of memory channels used for DPDK\n"); printf(" -p core master (primary) core for DPDK\n"); printf(" -s size memory size in MB for DPDK (default: %dMB)\n", defaults.mem_size); @@ -87,7 +86,7 @@ main(int argc, char *argv[]) vhost_app_opts_init(&opts); - while ((ch = getopt(argc, argv, "c:de:l:m:p:qs:S:t:h")) != -1) { + while ((ch = getopt(argc, argv, "c:de:m:p:qs:S:t:h")) != -1) { switch (ch) { case 'c': opts.config_file = optarg; @@ -101,9 +100,6 @@ main(int argc, char *argv[]) case 'h': usage(argv[0]); exit(EXIT_SUCCESS); - case 'l': - opts.log_facility = optarg; - break; case 'm': opts.reactor_mask = optarg; break; diff --git a/etc/spdk/iscsi.conf.in b/etc/spdk/iscsi.conf.in index 4953e5c6e..8ee044554 100644 --- a/etc/spdk/iscsi.conf.in +++ b/etc/spdk/iscsi.conf.in @@ -24,9 +24,6 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups. #TpointGroupMask 0x0 - # syslog facility - LogFacility "local7" - [iSCSI] # node name (not include optional part) # Users can optionally change this to fit their environment. diff --git a/etc/spdk/nvmf.conf.in b/etc/spdk/nvmf.conf.in index 3903eb309..c7f39ba55 100644 --- a/etc/spdk/nvmf.conf.in +++ b/etc/spdk/nvmf.conf.in @@ -20,9 +20,6 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups. #TpointGroupMask 0x0 - # syslog facility - LogFacility "local7" - [Rpc] # Defines whether to enable configuration via RPC. # Default is disabled. Note that the RPC interface is not diff --git a/etc/spdk/rocksdb.conf.in b/etc/spdk/rocksdb.conf.in index 03288f2fa..cbe7e92de 100644 --- a/etc/spdk/rocksdb.conf.in +++ b/etc/spdk/rocksdb.conf.in @@ -21,9 +21,6 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all events. #EventMask 0x0 - # syslog facility - LogFacility "local7" - [Rpc] # Defines whether spdk will enable configuration via RPC. # Default is disabled. Note that the RPC interface is not diff --git a/etc/spdk/vhost.conf.in b/etc/spdk/vhost.conf.in index 0dc05cfc2..b4d6b2236 100644 --- a/etc/spdk/vhost.conf.in +++ b/etc/spdk/vhost.conf.in @@ -24,9 +24,6 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups. #TpointGroupMask 0x0 - # syslog facility - LogFacility "local7" - [Rpc] # Defines whether SPDK vhost will enable configuration via RPC. # Default is disabled. Note that the RPC interface is not diff --git a/include/spdk/event.h b/include/spdk/event.h index 2a65f8de4..08c38da3e 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -69,7 +69,6 @@ struct spdk_app_opts { const char *name; const char *config_file; const char *reactor_mask; - const char *log_facility; const char *tpoint_group_mask; int shm_id; diff --git a/include/spdk/log.h b/include/spdk/log.h index 6c47a8a4b..658e57c24 100644 --- a/include/spdk/log.h +++ b/include/spdk/log.h @@ -91,9 +91,6 @@ enum spdk_log_level spdk_log_get_print_level(void); #define SPDK_ERRLOG(...) \ spdk_log(SPDK_LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__) -int spdk_set_log_facility(const char *facility); -const char *spdk_get_log_facility(void); - void spdk_log(enum spdk_log_level level, const char *file, const int line, const char *func, const char *format, ...) __attribute__((__format__(__printf__, 5, 6))); diff --git a/lib/event/app.c b/lib/event/app.c index c5064cef8..6f87af872 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -40,7 +40,6 @@ #include "spdk/conf.h" #include "spdk/trace.h" -#define SPDK_APP_DEFAULT_LOG_FACILITY "local7" #define SPDK_APP_DEFAULT_LOG_PRIORITY SPDK_LOG_INFO #define SPDK_APP_DPDK_DEFAULT_MEM_SIZE -1 @@ -92,24 +91,15 @@ spdk_app_get_shm_id(void) " # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups.\n" \ " TpointGroupMask \"0x%" PRIX64 "\"\n" \ "\n" \ -" # syslog facility\n" \ -" LogFacility \"%s\"\n" \ -"\n" static void spdk_app_config_dump_global_section(FILE *fp) { - const char *log_facility; - if (NULL == fp) return; - log_facility = spdk_get_log_facility(); - assert(log_facility != NULL); - fprintf(fp, GLOBAL_CONFIG_TMPL, - spdk_app_get_core_mask(), spdk_trace_get_tpoint_group_mask(), - log_facility); + spdk_app_get_core_mask(), spdk_trace_get_tpoint_group_mask()); } int @@ -158,25 +148,6 @@ spdk_app_get_running_config(char **config_str, char *name) return 0; } -static const char * -spdk_app_get_log_facility(struct spdk_conf *config) -{ - struct spdk_conf_section *sp; - const char *logfacility; - - sp = spdk_conf_find_section(config, "Global"); - if (sp == NULL) { - return SPDK_APP_DEFAULT_LOG_FACILITY; - } - - logfacility = spdk_conf_section_get_val(sp, "LogFacility"); - if (logfacility == NULL) { - return SPDK_APP_DEFAULT_LOG_FACILITY; - } - - return logfacility; -} - void spdk_app_start_shutdown(void) { @@ -206,7 +177,6 @@ spdk_app_opts_init(struct spdk_app_opts *opts) memset(opts, 0, sizeof(*opts)); - opts->log_facility = SPDK_APP_DEFAULT_LOG_FACILITY; opts->enable_coredump = true; opts->shm_id = -1; opts->mem_size = SPDK_APP_DPDK_DEFAULT_MEM_SIZE; @@ -272,22 +242,6 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, g_spdk_app.shm_id = opts->shm_id; g_spdk_app.shutdown_cb = opts->shutdown_cb; - /* open log files */ - if (opts->log_facility == NULL) { - opts->log_facility = spdk_app_get_log_facility(g_spdk_app.config); - if (opts->log_facility == NULL) { - SPDK_ERRLOG("NULL logfacility\n"); - spdk_conf_free(g_spdk_app.config); - exit(EXIT_FAILURE); - } - } - rc = spdk_set_log_facility(opts->log_facility); - if (rc < 0) { - SPDK_ERRLOG("log facility error\n"); - spdk_conf_free(g_spdk_app.config); - exit(EXIT_FAILURE); - } - spdk_log_set_level(SPDK_APP_DEFAULT_LOG_PRIORITY); spdk_log_open(); diff --git a/lib/log/log.c b/lib/log/log.c index ceadd4591..d9a893f71 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -37,7 +37,6 @@ static TAILQ_HEAD(, spdk_trace_flag) g_trace_flags = TAILQ_HEAD_INITIALIZER(g_trace_flags); -int spdk_g_log_facility = LOG_DAEMON; static enum spdk_log_level g_spdk_log_level = SPDK_LOG_NOTICE; static enum spdk_log_level g_spdk_log_print_level = SPDK_LOG_NOTICE; @@ -45,40 +44,6 @@ SPDK_LOG_REGISTER_TRACE_FLAG("debug", SPDK_TRACE_DEBUG) #define MAX_TMPBUF 1024 -struct syslog_code { - const char *c_name; - int c_val; -}; - -static const struct syslog_code facilitynames[] = { - { "auth", LOG_AUTH, }, - { "authpriv", LOG_AUTHPRIV, }, - { "cron", LOG_CRON, }, - { "daemon", LOG_DAEMON, }, - { "ftp", LOG_FTP, }, - { "kern", LOG_KERN, }, - { "lpr", LOG_LPR, }, - { "mail", LOG_MAIL, }, - { "news", LOG_NEWS, }, - { "syslog", LOG_SYSLOG, }, - { "user", LOG_USER, }, - { "uucp", LOG_UUCP, }, - { "local0", LOG_LOCAL0, }, - { "local1", LOG_LOCAL1, }, - { "local2", LOG_LOCAL2, }, - { "local3", LOG_LOCAL3, }, - { "local4", LOG_LOCAL4, }, - { "local5", LOG_LOCAL5, }, - { "local6", LOG_LOCAL6, }, - { "local7", LOG_LOCAL7, }, -#ifdef __FreeBSD__ - { "console", LOG_CONSOLE, }, - { "ntp", LOG_NTP, }, - { "security", LOG_SECURITY, }, -#endif - { NULL, -1, } -}; - static const char *const spdk_level_names[] = { [SPDK_LOG_ERROR] = "ERROR", [SPDK_LOG_WARN] = "WARNING", @@ -90,11 +55,7 @@ static const char *const spdk_level_names[] = { void spdk_log_open(void) { - if (spdk_g_log_facility != 0) { - openlog("spdk", LOG_PID, spdk_g_log_facility); - } else { - openlog("spdk", LOG_PID, LOG_DAEMON); - } + openlog("spdk", LOG_PID, LOG_LOCAL7); } void @@ -125,39 +86,6 @@ spdk_log_get_print_level(void) { return g_spdk_log_print_level; } -int -spdk_set_log_facility(const char *facility) -{ - int i; - - for (i = 0; facilitynames[i].c_name != NULL; i++) { - if (strcasecmp(facilitynames[i].c_name, facility) == 0) { - spdk_g_log_facility = facilitynames[i].c_val; - return 0; - } - } - - spdk_g_log_facility = LOG_DAEMON; - return -1; -} - -const char * -spdk_get_log_facility(void) -{ - const char *def_name = NULL; - int i; - - for (i = 0; facilitynames[i].c_name != NULL; i++) { - if (facilitynames[i].c_val == spdk_g_log_facility) { - return facilitynames[i].c_name; - } else if (facilitynames[i].c_val == LOG_DAEMON) { - def_name = facilitynames[i].c_name; - } - } - - return def_name; -} - void spdk_log(enum spdk_log_level level, const char *file, const int line, const char *func, const char *format, ...) diff --git a/test/iscsi_tgt/calsoft/iscsi.conf b/test/iscsi_tgt/calsoft/iscsi.conf index a63fefb8f..bb7fa296d 100644 --- a/test/iscsi_tgt/calsoft/iscsi.conf +++ b/test/iscsi_tgt/calsoft/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/ext4test/iscsi.conf.in b/test/iscsi_tgt/ext4test/iscsi.conf.in index 588e424ab..bb7219b65 100644 --- a/test/iscsi_tgt/ext4test/iscsi.conf.in +++ b/test/iscsi_tgt/ext4test/iscsi.conf.in @@ -1,6 +1,5 @@ [Global] Comment "Global section" - LogFacility "local7" [iSCSI] NodeBase "iqn.2013-06.com.intel.ch.spdk" diff --git a/test/iscsi_tgt/filesystem/iscsi.conf b/test/iscsi_tgt/filesystem/iscsi.conf index bcc80a845..fde6fbf6c 100644 --- a/test/iscsi_tgt/filesystem/iscsi.conf +++ b/test/iscsi_tgt/filesystem/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/fio/iscsi.conf.in b/test/iscsi_tgt/fio/iscsi.conf.in index bcc80a845..fde6fbf6c 100644 --- a/test/iscsi_tgt/fio/iscsi.conf.in +++ b/test/iscsi_tgt/fio/iscsi.conf.in @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/idle_migration/iscsi.conf b/test/iscsi_tgt/idle_migration/iscsi.conf index 1a25fbf19..eae370033 100644 --- a/test/iscsi_tgt/idle_migration/iscsi.conf +++ b/test/iscsi_tgt/idle_migration/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/ip_migration/iscsi.conf b/test/iscsi_tgt/ip_migration/iscsi.conf index 778508ad8..440b4db80 100644 --- a/test/iscsi_tgt/ip_migration/iscsi.conf +++ b/test/iscsi_tgt/ip_migration/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/nvme_remote/iscsi.conf b/test/iscsi_tgt/nvme_remote/iscsi.conf index b59d534a0..410b16a81 100644 --- a/test/iscsi_tgt/nvme_remote/iscsi.conf +++ b/test/iscsi_tgt/nvme_remote/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/rbd/iscsi.conf b/test/iscsi_tgt/rbd/iscsi.conf index bcc80a845..fde6fbf6c 100644 --- a/test/iscsi_tgt/rbd/iscsi.conf +++ b/test/iscsi_tgt/rbd/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/reset/iscsi.conf b/test/iscsi_tgt/reset/iscsi.conf index bcc80a845..fde6fbf6c 100644 --- a/test/iscsi_tgt/reset/iscsi.conf +++ b/test/iscsi_tgt/reset/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/iscsi_tgt/rpc_config/iscsi.conf b/test/iscsi_tgt/rpc_config/iscsi.conf index bcc80a845..fde6fbf6c 100644 --- a/test/iscsi_tgt/rpc_config/iscsi.conf +++ b/test/iscsi_tgt/rpc_config/iscsi.conf @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [iSCSI] NodeBase "iqn.2016-06.io.spdk" diff --git a/test/nvmf/nvmf.conf b/test/nvmf/nvmf.conf index b1c452a39..1f36711f6 100644 --- a/test/nvmf/nvmf.conf +++ b/test/nvmf/nvmf.conf @@ -1,6 +1,5 @@ [Global] Comment "Global section" - LogFacility "local7" [Rpc] Enable Yes diff --git a/test/unit/lib/log/log.c/log_ut.c b/test/unit/lib/log/log.c/log_ut.c index 90658a193..cf432d17c 100644 --- a/test/unit/lib/log/log.c/log_ut.c +++ b/test/unit/lib/log/log.c/log_ut.c @@ -41,25 +41,6 @@ static void log_test(void) { - int rc = 0; - const char *buf; - - rc = spdk_set_log_facility("test"); - CU_ASSERT(rc == -1); - CU_ASSERT_EQUAL(spdk_g_log_facility, LOG_DAEMON); - rc = spdk_set_log_facility("local7"); - CU_ASSERT(rc == 0); - CU_ASSERT_EQUAL(spdk_g_log_facility, LOG_LOCAL7); - - spdk_g_log_facility = -1; - buf = spdk_get_log_facility(); - SPDK_CU_ASSERT_FATAL(buf != NULL); - CU_ASSERT_STRING_EQUAL(buf, "daemon"); - spdk_g_log_facility = LOG_LOCAL7; - buf = spdk_get_log_facility(); - SPDK_CU_ASSERT_FATAL(buf != NULL); - CU_ASSERT_STRING_EQUAL(buf, "local7"); - spdk_log_set_level(SPDK_LOG_ERROR); CU_ASSERT_EQUAL(spdk_log_get_level(), SPDK_LOG_ERROR); spdk_log_set_level(SPDK_LOG_WARN); diff --git a/test/vhost/fiotest/vhost.conf.in b/test/vhost/fiotest/vhost.conf.in index d9a9d2709..c86bd21bb 100644 --- a/test/vhost/fiotest/vhost.conf.in +++ b/test/vhost/fiotest/vhost.conf.in @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [Rpc] Enable Yes diff --git a/test/vhost/integrity/vhost.conf.in b/test/vhost/integrity/vhost.conf.in index 39edd5b56..169ec9663 100644 --- a/test/vhost/integrity/vhost.conf.in +++ b/test/vhost/integrity/vhost.conf.in @@ -1,5 +1,4 @@ [Global] - LogFacility "local7" [Rpc] Enable Yes