[v3,1/2] eal: unify logging code for FreeBsd and Linux

Message ID 20230306192810.106154-2-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Add option to timestamp console log |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger March 6, 2023, 7:28 p.m. UTC
  FreeBSD logging code was not using syslog and did not have
the same options as Linux. Move the log writing code to common
tree.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/freebsd/eal.c             | 7 +++++++
 lib/eal/linux/meson.build         | 1 -
 lib/eal/{linux => unix}/eal_log.c | 0
 lib/eal/unix/meson.build          | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
 rename lib/eal/{linux => unix}/eal_log.c (100%)
  

Patch

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 7db4239c5187..3a53f9e13887 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -51,6 +51,7 @@ 
 #include "eal_hugepages.h"
 #include "eal_options.h"
 #include "eal_memcfg.h"
+#include "eal_log.h"
 #include "eal_trace.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
@@ -744,6 +745,12 @@  rte_eal_init(int argc, char **argv)
 #endif
 	}
 
+	if (eal_log_init(getprogname(), internal_conf->syslog_facility) < 0) {
+		rte_eal_init_alert("Cannot init logging.");
+		rte_errno = ENOMEM;
+		return -1;
+	}
+
 	/* in secondary processes, memory init may allocate additional fbarrays
 	 * not present in primary processes, so to avoid any potential issues,
 	 * initialize memzones first.
diff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build
index 3cccfa36c0a4..1b913acc0681 100644
--- a/lib/eal/linux/meson.build
+++ b/lib/eal/linux/meson.build
@@ -11,7 +11,6 @@  sources += files(
         'eal_hugepage_info.c',
         'eal_interrupts.c',
         'eal_lcore.c',
-        'eal_log.c',
         'eal_memalloc.c',
         'eal_memory.c',
         'eal_thread.c',
diff --git a/lib/eal/linux/eal_log.c b/lib/eal/unix/eal_log.c
similarity index 100%
rename from lib/eal/linux/eal_log.c
rename to lib/eal/unix/eal_log.c
diff --git a/lib/eal/unix/meson.build b/lib/eal/unix/meson.build
index cc7d67dd321d..37d07594df29 100644
--- a/lib/eal/unix/meson.build
+++ b/lib/eal/unix/meson.build
@@ -6,6 +6,7 @@  sources += files(
         'eal_file.c',
         'eal_filesystem.c',
         'eal_firmware.c',
+        'eal_log.c',
         'eal_unix_memory.c',
         'eal_unix_thread.c',
         'eal_unix_timer.c',