log: Use SPDK_ERRLOG in lieu of fprintf(stderr
Change-Id: Ic87d62516324b9c388a932b268714255b15a9a57 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
70f8a8e2f4
commit
2d2fde0d7f
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "spdk/conf.h"
|
#include "spdk/conf.h"
|
||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
|
#include "spdk/log.h"
|
||||||
|
|
||||||
struct spdk_conf_value {
|
struct spdk_conf_value {
|
||||||
struct spdk_conf_value *next;
|
struct spdk_conf_value *next;
|
||||||
@ -262,7 +263,7 @@ append_cf_section(struct spdk_conf *cp, struct spdk_conf_section *sp)
|
|||||||
|
|
||||||
cp = CHECK_CP_OR_USE_DEFAULT(cp);
|
cp = CHECK_CP_OR_USE_DEFAULT(cp);
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
fprintf(stderr, "%s: cp == NULL\n", __func__);
|
SPDK_ERRLOG("cp == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +458,7 @@ parse_line(struct spdk_conf *cp, char *lp)
|
|||||||
|
|
||||||
arg = spdk_str_trim(lp);
|
arg = spdk_str_trim(lp);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
fprintf(stderr, "no section\n");
|
SPDK_ERRLOG("no section\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +467,7 @@ parse_line(struct spdk_conf *cp, char *lp)
|
|||||||
arg++;
|
arg++;
|
||||||
key = spdk_strsepq(&arg, "]");
|
key = spdk_strsepq(&arg, "]");
|
||||||
if (key == NULL || arg != NULL) {
|
if (key == NULL || arg != NULL) {
|
||||||
fprintf(stderr, "broken section\n");
|
SPDK_ERRLOG("broken section\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* determine section number */
|
/* determine section number */
|
||||||
@ -495,18 +496,18 @@ parse_line(struct spdk_conf *cp, char *lp)
|
|||||||
/* parameters */
|
/* parameters */
|
||||||
sp = cp->current_section;
|
sp = cp->current_section;
|
||||||
if (sp == NULL) {
|
if (sp == NULL) {
|
||||||
fprintf(stderr, "unknown section\n");
|
SPDK_ERRLOG("unknown section\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
key = spdk_strsepq(&arg, CF_DELIM);
|
key = spdk_strsepq(&arg, CF_DELIM);
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
fprintf(stderr, "broken key\n");
|
SPDK_ERRLOG("broken key\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = allocate_cf_item();
|
ip = allocate_cf_item();
|
||||||
if (ip == NULL) {
|
if (ip == NULL) {
|
||||||
fprintf(stderr, "cannot allocate cf item\n");
|
SPDK_ERRLOG("cannot allocate cf item\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
append_cf_item(sp, ip);
|
append_cf_item(sp, ip);
|
||||||
@ -522,8 +523,7 @@ parse_line(struct spdk_conf *cp, char *lp)
|
|||||||
val = spdk_strsepq(&arg, CF_DELIM);
|
val = spdk_strsepq(&arg, CF_DELIM);
|
||||||
vp = allocate_cf_value();
|
vp = allocate_cf_value();
|
||||||
if (vp == NULL) {
|
if (vp == NULL) {
|
||||||
fprintf(stderr,
|
SPDK_ERRLOG("cannot allocate cf value\n");
|
||||||
"cannot allocate cf value\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
append_cf_value(ip, vp);
|
append_cf_value(ip, vp);
|
||||||
@ -611,7 +611,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)
|
|||||||
|
|
||||||
fp = fopen(file, "r");
|
fp = fopen(file, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fprintf(stderr, "open error: %s\n", file);
|
SPDK_ERRLOG("open error: %s\n", file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)
|
|||||||
if (!q) {
|
if (!q) {
|
||||||
free(lp2);
|
free(lp2);
|
||||||
free(lp);
|
free(lp);
|
||||||
fprintf(stderr, "malloc failed at line %d of %s\n", line, cp->file);
|
SPDK_ERRLOG("malloc failed at line %d of %s\n", line, cp->file);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -664,7 +664,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file)
|
|||||||
|
|
||||||
/* parse one line */
|
/* parse one line */
|
||||||
if (parse_line(cp, p) < 0) {
|
if (parse_line(cp, p) < 0) {
|
||||||
fprintf(stderr, "parse error at line %d of %s\n", line, cp->file);
|
SPDK_ERRLOG("parse error at line %d of %s\n", line, cp->file);
|
||||||
}
|
}
|
||||||
next_line:
|
next_line:
|
||||||
line++;
|
line++;
|
||||||
|
@ -128,12 +128,12 @@ spdk_app_get_running_config(char **config_str, char *name)
|
|||||||
/* Create temporary file to hold config */
|
/* Create temporary file to hold config */
|
||||||
fd = mkstemp(config_template);
|
fd = mkstemp(config_template);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
fprintf(stderr, "mkstemp failed\n");
|
SPDK_ERRLOG("mkstemp failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fp = fdopen(fd, "wb+");
|
fp = fdopen(fd, "wb+");
|
||||||
if (NULL == fp) {
|
if (NULL == fp) {
|
||||||
fprintf(stderr, "error opening tmpfile fd = %d\n", fd);
|
SPDK_ERRLOG("error opening tmpfile fd = %d\n", fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ spdk_app_get_running_config(char **config_str, char *name)
|
|||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
ret = fread(*config_str, sizeof(char), length, fp);
|
ret = fread(*config_str, sizeof(char), length, fp);
|
||||||
if (ret < length)
|
if (ret < length)
|
||||||
fprintf(stderr, "%s: warning - short read\n", __func__);
|
SPDK_ERRLOG("short read\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
(*config_str)[length] = '\0';
|
(*config_str)[length] = '\0';
|
||||||
|
|
||||||
@ -244,12 +244,12 @@ spdk_app_init(struct spdk_app_opts *opts)
|
|||||||
if (opts->config_file) {
|
if (opts->config_file) {
|
||||||
rc = spdk_conf_read(config, opts->config_file);
|
rc = spdk_conf_read(config, opts->config_file);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
fprintf(stderr, "Could not read config file %s\n", opts->config_file);
|
SPDK_ERRLOG("Could not read config file %s\n", opts->config_file);
|
||||||
spdk_conf_free(config);
|
spdk_conf_free(config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (spdk_conf_first_section(config) == NULL) {
|
if (spdk_conf_first_section(config) == NULL) {
|
||||||
fprintf(stderr, "Invalid config file %s\n", opts->config_file);
|
SPDK_ERRLOG("Invalid config file %s\n", opts->config_file);
|
||||||
spdk_conf_free(config);
|
spdk_conf_free(config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -272,21 +272,21 @@ spdk_app_init(struct spdk_app_opts *opts)
|
|||||||
if (opts->log_facility == NULL) {
|
if (opts->log_facility == NULL) {
|
||||||
opts->log_facility = spdk_app_get_log_facility(g_spdk_app.config);
|
opts->log_facility = spdk_app_get_log_facility(g_spdk_app.config);
|
||||||
if (opts->log_facility == NULL) {
|
if (opts->log_facility == NULL) {
|
||||||
fprintf(stderr, "NULL logfacility\n");
|
SPDK_ERRLOG("NULL logfacility\n");
|
||||||
spdk_conf_free(g_spdk_app.config);
|
spdk_conf_free(g_spdk_app.config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = spdk_set_log_facility(opts->log_facility);
|
rc = spdk_set_log_facility(opts->log_facility);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "log facility error\n");
|
SPDK_ERRLOG("log facility error\n");
|
||||||
spdk_conf_free(g_spdk_app.config);
|
spdk_conf_free(g_spdk_app.config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = spdk_set_log_priority(SPDK_APP_DEFAULT_LOG_PRIORITY);
|
rc = spdk_set_log_priority(SPDK_APP_DEFAULT_LOG_PRIORITY);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "log priority error\n");
|
SPDK_ERRLOG("log priority error\n");
|
||||||
spdk_conf_free(g_spdk_app.config);
|
spdk_conf_free(g_spdk_app.config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ spdk_app_init(struct spdk_app_opts *opts)
|
|||||||
* reactor.
|
* reactor.
|
||||||
*/
|
*/
|
||||||
if (spdk_reactors_init(opts->max_delay_us)) {
|
if (spdk_reactors_init(opts->max_delay_us)) {
|
||||||
fprintf(stderr, "Invalid reactor mask.\n");
|
SPDK_ERRLOG("Invalid reactor mask.\n");
|
||||||
spdk_conf_free(g_spdk_app.config);
|
spdk_conf_free(g_spdk_app.config);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
|
#include "spdk/log.h"
|
||||||
|
|
||||||
#include "spdk_internal/event.h"
|
#include "spdk_internal/event.h"
|
||||||
|
|
||||||
static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
|
static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
|
||||||
@ -116,12 +118,12 @@ spdk_subsystem_init(void)
|
|||||||
/* Verify that all dependency name and depends_on subsystems are registered */
|
/* Verify that all dependency name and depends_on subsystems are registered */
|
||||||
TAILQ_FOREACH(dep, &g_depends, tailq) {
|
TAILQ_FOREACH(dep, &g_depends, tailq) {
|
||||||
if (!spdk_subsystem_find(&g_subsystems, dep->name)) {
|
if (!spdk_subsystem_find(&g_subsystems, dep->name)) {
|
||||||
fprintf(stderr, "subsystem %s is missing\n", dep->name);
|
SPDK_ERRLOG("subsystem %s is missing\n", dep->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!spdk_subsystem_find(&g_subsystems, dep->depends_on)) {
|
if (!spdk_subsystem_find(&g_subsystems, dep->depends_on)) {
|
||||||
fprintf(stderr, "subsystem %s dependency %s is missing\n",
|
SPDK_ERRLOG("subsystem %s dependency %s is missing\n",
|
||||||
dep->name, dep->depends_on);
|
dep->name, dep->depends_on);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,12 +300,12 @@ spdk_log_register_trace_flag(const char *name, struct spdk_trace_flag *flag)
|
|||||||
struct spdk_trace_flag *iter;
|
struct spdk_trace_flag *iter;
|
||||||
|
|
||||||
if (name == NULL || flag == NULL) {
|
if (name == NULL || flag == NULL) {
|
||||||
fprintf(stderr, "missing spdk_trace_flag parameters\n");
|
SPDK_ERRLOG("missing spdk_trace_flag parameters\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_trace_flag(name)) {
|
if (get_trace_flag(name)) {
|
||||||
fprintf(stderr, "duplicate spdk_trace_flag '%s'\n", name);
|
SPDK_ERRLOG("duplicate spdk_trace_flag '%s'\n", name);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user