[v7,4/5] eal: allow user to set default log stream before init
Checks
Commit Message
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_openlog_stream(stderr);
There is no reason for helper command line applications to clutter
syslog with messages.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/dumpcap/main.c | 3 +++
app/pdump/main.c | 3 +++
app/proc-info/main.c | 3 +++
lib/eal/common/eal_common_log.c | 6 ++++++
lib/eal/common/eal_log.h | 1 +
lib/eal/unix/eal_log.c | 4 ++++
6 files changed, 20 insertions(+)
@@ -639,6 +639,9 @@ static void dpdk_init(void)
eal_argv[i++] = strdup(file_prefix);
}
+ /* keep any logging away from syslog. */
+ rte_openlog_stream(stderr);
+
if (rte_eal_init(eal_argc, eal_argv) < 0)
rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n");
}
@@ -989,6 +989,9 @@ main(int argc, char **argv)
argc += 2;
+ /* keep any logging away from syslog. */
+ rte_openlog_stream(stderr);
+
diag = rte_eal_init(argc, argp);
if (diag < 0)
rte_panic("Cannot init EAL\n");
@@ -1774,6 +1774,9 @@ main(int argc, char **argv)
argc += 4;
+ /* keep any logging away from syslog. */
+ rte_openlog_stream(stderr);
+
ret = rte_eal_init(argc, argp);
if (ret < 0)
rte_panic("Cannot init EAL\n");
@@ -584,6 +584,12 @@ eal_log_set_default(FILE *default_log)
#endif
}
+FILE *
+eal_log_get_default(void)
+{
+ return default_log_stream;
+}
+
/*
* Called by eal_cleanup
*/
@@ -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.
@@ -60,6 +60,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;