diff --git a/CHANGELOG.md b/CHANGELOG.md index 848a56057..2e6eb07c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,10 @@ The ability to set a thread name, previously only used by the reactor code, is now part of the `spdk_thread_allocate()` API. Users may specify a thread name which will show up in tools like `gdb`. +### Log + +The API spdk_trace_dump() now takes a new parameter to allow the caller to +specify stdout or stderr for example. ## v17.07: Build system improvements, userspace vhost-blk target, and GPT bdev diff --git a/include/spdk/log.h b/include/spdk/log.h index 658e57c24..535620417 100644 --- a/include/spdk/log.h +++ b/include/spdk/log.h @@ -94,7 +94,7 @@ enum spdk_log_level spdk_log_get_print_level(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))); -void spdk_trace_dump(const char *label, const uint8_t *buf, size_t len); +void spdk_trace_dump(FILE *fp, const char *label, const uint8_t *buf, size_t len); bool spdk_log_get_trace_flag(const char *flag); int spdk_log_set_trace_flag(const char *flag); diff --git a/include/spdk_internal/log.h b/include/spdk_internal/log.h index 6eb179f04..764dc9357 100644 --- a/include/spdk_internal/log.h +++ b/include/spdk_internal/log.h @@ -85,7 +85,7 @@ __attribute__((constructor)) static void register_trace_flag_##flag(void) \ do { \ extern struct spdk_trace_flag FLAG; \ if ((FLAG.enabled) && (LEN)) { \ - spdk_trace_dump((LABEL), (BUF), (LEN)); \ + spdk_trace_dump(stderr, (LABEL), (BUF), (LEN)); \ } \ } while (0) diff --git a/lib/log/log.c b/lib/log/log.c index ba7b7f3ca..0e4e43448 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -166,9 +166,9 @@ fdump(FILE *fp, const char *label, const uint8_t *buf, size_t len) } void -spdk_trace_dump(const char *label, const uint8_t *buf, size_t len) +spdk_trace_dump(FILE *fp, const char *label, const uint8_t *buf, size_t len) { - fdump(stderr, label, buf, len); + fdump(fp, label, buf, len); } static struct spdk_trace_flag * diff --git a/test/unit/lib/log/log.c/log_ut.c b/test/unit/lib/log/log.c/log_ut.c index 9af932af7..615ee6301 100644 --- a/test/unit/lib/log/log.c/log_ut.c +++ b/test/unit/lib/log/log.c/log_ut.c @@ -67,7 +67,7 @@ log_test(void) SPDK_WARNLOG("log warning unit test\n"); SPDK_DEBUGLOG(SPDK_TRACE_LOG, "log trace test\n"); SPDK_TRACEDUMP(SPDK_TRACE_LOG, "log trace dump test:", "trace dump", 10); - spdk_trace_dump("spdk dump test:", "spdk dump", 9); + spdk_trace_dump(stderr, "spdk dump test:", "spdk dump", 9); spdk_log_close(); }