[v8,3/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/log/log.c | 6 ++++++
lib/log/log_internal.h | 2 ++
lib/log/log_unix.c | 4 ++++
lib/log/version.map | 1 +
7 files changed, 22 insertions(+)
@@ -633,6 +633,9 @@ static void dpdk_init(void)
rte_panic("No memory\n");
}
+ /* 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");
}
@@ -995,6 +995,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");
@@ -2149,6 +2149,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");
@@ -519,6 +519,12 @@ eal_log_set_default(FILE *default_log)
#endif
}
+FILE *
+eal_log_get_default(void)
+{
+ return default_log_stream;
+}
+
/*
* Called by eal_cleanup
*/
@@ -21,6 +21,8 @@ int eal_log_init(const char *id, int facility);
*/
__rte_internal
void eal_log_set_default(FILE *default_log);
+__rte_internal
+FILE *eal_log_get_default(void);
/*
* Save a log option for later.
@@ -49,6 +49,10 @@ eal_log_init(const char *id, int facility)
{
FILE *log_stream;
+ /* skip if 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;
@@ -25,6 +25,7 @@ DPDK_24 {
INTERNAL {
global:
+ eal_log_get_default;
eal_log_init;
eal_log_level2str;
eal_log_save_pattern;