From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F64643CE8; Mon, 18 Mar 2024 19:32:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3D7B40696; Mon, 18 Mar 2024 19:32:47 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id BA7634027F for ; Mon, 18 Mar 2024 19:32:45 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e6afb754fcso4438294b3a.3 for ; Mon, 18 Mar 2024 11:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786765; x=1711391565; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=37akOt+01Du3dsCF3OJ9MabMFuRbj1LJQ50GxELecLs=; b=zsafVJNRIj1QccTrzoa7q6pIABVnSo5/iuMkYO+yvAd33Di2VTHRxtmF2weVMjVYxa RQiYzoryiwg7Fg/67p01FPDfAON2jCRN/mtiz3kx0PnyrtI3aX1GAexo09JjFMrduaRm JZ1RwFNY/PzIJihsal7cbuksYZBqThU63yCSN4KEEzuayzdncqr6Yu2mx2fhA65NfIIS GbTBvdGT8lvPrQ+CdzXltbyKwVgnPC3PIfGMXRCbLKV52SftYuUxBV2Yv48IEKTiNJOS Y5XFXcPflq7ICPXGqb1dDH/epCuedf7xUMXEHH2B/ecE9Ztzen9kNU5Xw5iRv3XUxNhB 8BDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786765; x=1711391565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=37akOt+01Du3dsCF3OJ9MabMFuRbj1LJQ50GxELecLs=; b=PeI5m9LRREyZqS3om4hQnOGwveiQq2roBmPx+OIuYYzmTYNketqh4jM2XKwB/r3kKP eBEBDEhjmzK7AG9xzibQXVmBJusuPdLetoe6GjOkP1b/Fz6E4dm8goJvCpqy/ocvx1Sh fpSSO46u49uTD/aD7KOpQgT53DnNGCAXi2lrV4VYlaNyzRCsKtJKMhLkUYGpLNSjdBWk EoXmGJIcsMHUUedVQdOWi/wp9hgi94fD22yUStd90R8osmarFNG/8spB1U2eDvOtrhaq rvhj82Q3xpE2YqWIZLJzJVusC53FMCoETzusoyg8jiztpBsLT9EpomKn+leE0o7d8iZm TinA== X-Gm-Message-State: AOJu0Yz7sXIDxnQzMq5Mz6YEf29VntTvR/puWZ9uaCCA1TrEUe4gnmF8 vOYluEQ2ADHLgkNGdlXxfSKbcL8eusRVbY0KQAxdPAnTr2FXTRMf+hqv2PewAjQw2eUW1WlFynE B X-Google-Smtp-Source: AGHT+IHy4f1M9mw7xzAqGFH+JHcHavXidNSJ009rlTCsMpThlWctkRgBt+BqM/wNM7TcQGBRjXXhgw== X-Received: by 2002:a05:6a00:847:b0:6e6:4f67:8440 with SMTP id q7-20020a056a00084700b006e64f678440mr15786680pfk.1.1710786764720; Mon, 18 Mar 2024 11:32:44 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id x6-20020aa784c6000000b006e4e93f4f17sm8186593pfn.117.2024.03.18.11.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:44 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 1/5] log: unify logging code Date: Mon, 18 Mar 2024 11:30:02 -0700 Message-ID: <20240318183233.142330-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318183233.142330-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318183233.142330-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org FreeBSD and Linux logging code can use common code. This also fixes FreeBSD not using syslog. Signed-off-by: Stephen Hemminger --- doc/guides/linux_gsg/linux_eal_parameters.rst | 27 ------------------- doc/guides/prog_guide/log_lib.rst | 18 +++++++++++-- lib/eal/freebsd/eal.c | 8 ++++++ lib/log/log_freebsd.c | 12 --------- lib/log/{log_linux.c => log_unix.c} | 0 lib/log/meson.build | 12 ++++++--- 6 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 lib/log/log_freebsd.c rename lib/log/{log_linux.c => log_unix.c} (100%) diff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst index ea8f38139119..d86f94d8a85d 100644 --- a/doc/guides/linux_gsg/linux_eal_parameters.rst +++ b/doc/guides/linux_gsg/linux_eal_parameters.rst @@ -108,30 +108,3 @@ Memory-related options * ``--match-allocations`` Free hugepages back to system exactly as they were originally allocated. - -Other options -~~~~~~~~~~~~~ - -* ``--syslog `` - - Set syslog facility. Valid syslog facilities are:: - - auth - cron - daemon - ftp - kern - lpr - mail - news - syslog - user - uucp - local0 - local1 - local2 - local3 - local4 - local5 - local6 - local7 diff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst index ff9d1b54a2c8..aacb36c36ce0 100644 --- a/doc/guides/prog_guide/log_lib.rst +++ b/doc/guides/prog_guide/log_lib.rst @@ -5,8 +5,8 @@ Log Library =========== The DPDK Log library provides the logging functionality for other DPDK libraries and drivers. -By default, in a Linux application, logs are sent to syslog and also to the console. -On FreeBSD and Windows applications, logs are sent only to the console. +By default, in a Linux (or FreeBSD) application, logs are sent to syslog and also to the console. +In Windows applications, logs are sent only to the console. However, the log function can be overridden by the user to use a different logging mechanism. Log Levels @@ -29,6 +29,7 @@ will be emitted by the application to the log output. That level can be configured either by the application calling the relevant APIs from the logging library, or by the user passing the ``--log-level`` parameter to the EAL via the application. + Setting Global Log Level ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -59,6 +60,19 @@ For example:: Within an application, the same result can be got using the ``rte_log_set_level_pattern()`` or ``rte_log_set_level_regex()`` APIs. + +Setting syslog facility +~~~~~~~~~~~~~~~~~~~~~~~ + +On Linux and FreeBSD, where syslog is used a ``facility`` argument can be +used to specify what type of program is logging. +The default facility is ``daemon`` but it can be overridden +by the ``--syslog`` EAL parameter. See ``syslog.3`` man page for full values. +For example:: + + /path/to/app --syslog local0 + + Using Logging APIs to Generate Log Messages ------------------------------------------- diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index bab77118e967..004b8fad2db3 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -760,6 +760,14 @@ rte_eal_init(int argc, char **argv) #endif } + if (eal_log_init(program_invocation_short_name, + internal_conf->syslog_facility) < 0) { + rte_eal_init_alert("Cannot init logging."); + rte_errno = ENOMEM; + rte_atomic_store_explicit(&run_once, 0, rte_memory_order_relaxed); + 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/log/log_freebsd.c b/lib/log/log_freebsd.c deleted file mode 100644 index 698d3c542337..000000000000 --- a/lib/log/log_freebsd.c +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2023 Intel Corporation - */ - -#include -#include "log_internal.h" - -int -eal_log_init(__rte_unused const char *id, __rte_unused int facility) -{ - return 0; -} diff --git a/lib/log/log_linux.c b/lib/log/log_unix.c similarity index 100% rename from lib/log/log_linux.c rename to lib/log/log_unix.c diff --git a/lib/log/meson.build b/lib/log/meson.build index 0d4319b36f77..60516a0b2a2d 100644 --- a/lib/log/meson.build +++ b/lib/log/meson.build @@ -2,8 +2,12 @@ # Copyright(c) 2023 Intel Corporation includes += global_inc -sources = files( - 'log.c', - 'log_' + exec_env + '.c', -) +sources = files('log.c') + +if is_windows + sources += files('log_windows.c') +else + sources += files('log_unix.c') +endif + headers = files('rte_log.h') -- 2.43.0