It is useful for application to be able to set the default log stream before call rte_eal_init(). This makes all messages go to the new default.
For example, to skip using syslog; just doing rte_log_set_default(stderr); Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- lib/eal/common/eal_common_log.c | 6 ++++++ lib/eal/common/eal_log.h | 1 + lib/eal/unix/eal_log.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..9b158c201205 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -535,6 +535,12 @@ eal_log_set_default(FILE *default_log) #endif } +FILE * +eal_log_get_default(void) +{ + return default_log_stream; +} + /* * Called by eal_cleanup */ diff --git a/lib/eal/common/eal_log.h b/lib/eal/common/eal_log.h index 31dc489350f6..268c2a264382 100644 --- a/lib/eal/common/eal_log.h +++ b/lib/eal/common/eal_log.h @@ -22,6 +22,7 @@ int eal_log_level_parse(int argc, char * const argv[]); * Determine where log data is written when no call to rte_openlog_stream. */ void eal_log_set_default(FILE *default_log); +FILE *eal_log_get_default(void); /* * Save a log option for later. diff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c index 7921417b050a..3bfe5853095f 100644 --- a/lib/eal/unix/eal_log.c +++ b/lib/eal/unix/eal_log.c @@ -113,6 +113,10 @@ eal_log_init(const char *id, int facility) { FILE *log_stream; + /* has user has already setup a log stream */ + if (eal_log_get_default()) + return 0; + log_stream = fopencookie(NULL, "w+", console_log_func); if (log_stream == NULL) return -1; -- 2.39.2