[v5,3/6] eal: fix handling of syslog facility

Message ID 20230628175827.471909-4-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Logging related patches |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger June 28, 2023, 5:58 p.m. UTC
  The syslog facility option needs to be parsed before log_init
is called. Also help message whas missing the required argument.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/common/eal_common_options.c | 2 +-
 lib/eal/freebsd/eal.c               | 2 +-
 lib/eal/linux/eal.c                 | 2 +-
 lib/eal/unix/eal_log.c              | 1 +
 4 files changed, 4 insertions(+), 3 deletions(-)
  

Patch

diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 03059336987d..005da4d12001 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -2193,7 +2193,7 @@  eal_common_usage(void)
 	       "  --"OPT_VMWARE_TSC_MAP"    Use VMware TSC map instead of native RDTSC\n"
 	       "  --"OPT_PROC_TYPE"         Type of this process (primary|secondary|auto)\n"
 #ifndef RTE_EXEC_ENV_WINDOWS
-	       "  --"OPT_SYSLOG"            Set syslog facility\n"
+	       "  --"OPT_SYSLOG"=<facility> Set syslog facility\n"
 #endif
 	       "  --"OPT_LOG_LEVEL"=<level> Set global log level\n"
 	       "  --"OPT_LOG_LEVEL"=<type-match>:<level>\n"
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index bb9a2b1653d9..104507b61514 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -394,7 +394,7 @@  eal_parse_args(int argc, char **argv)
 		}
 
 		/* eal_log_level_parse() already handled this option */
-		if (opt == OPT_LOG_LEVEL_NUM)
+		if (opt == OPT_LOG_LEVEL_NUM || opt == OPT_SYSLOG_NUM)
 			continue;
 
 		ret = eal_parse_common_option(opt, optarg, internal_conf);
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index d7f268fc8116..e30c44380e30 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -611,7 +611,7 @@  eal_parse_args(int argc, char **argv)
 		}
 
 		/* eal_log_level_parse() already handled these */
-		if (opt == OPT_LOG_LEVEL_NUM)
+		if (opt == OPT_LOG_LEVEL_NUM || opt == OPT_SYSLOG_NUM)
 			continue;
 
 		ret = eal_parse_common_option(opt, optarg, internal_conf);
diff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c
index 3f54284494d7..93cf04fae043 100644
--- a/lib/eal/unix/eal_log.c
+++ b/lib/eal/unix/eal_log.c
@@ -80,6 +80,7 @@  eal_log_level_parse(int argc, char *const argv[])
 				  eal_long_options, &option_index)) != EOF) {
 
 		switch (opt) {
+		case OPT_SYSLOG_NUM:
 		case OPT_LOG_LEVEL_NUM:
 			if (eal_parse_common_option(opt, optarg, internal_conf) < 0)
 				return -1;