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 <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365295
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2017-06-13 11:48:28 -07:00 committed by Jim Harris
parent cbe5074056
commit ad474e95bb
25 changed files with 5 additions and 185 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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)));

View File

@ -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();

View File

@ -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, ...)

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,6 +1,5 @@
[Global]
Comment "Global section"
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2013-06.com.intel.ch.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[iSCSI]
NodeBase "iqn.2016-06.io.spdk"

View File

@ -1,6 +1,5 @@
[Global]
Comment "Global section"
LogFacility "local7"
[Rpc]
Enable Yes

View File

@ -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);

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[Rpc]
Enable Yes

View File

@ -1,5 +1,4 @@
[Global]
LogFacility "local7"
[Rpc]
Enable Yes