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 15D6443D17; Thu, 21 Mar 2024 17:12:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF83942DC3; Thu, 21 Mar 2024 17:12:04 +0100 (CET) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 1D20E427E1 for ; Thu, 21 Mar 2024 17:12:03 +0100 (CET) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e6a9fafacdso964828b3a.2 for ; Thu, 21 Mar 2024 09:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1711037522; x=1711642322; 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=IQQWfLs/rkE7rpozeif9leaDk6Fe1YevxA9gj3J8Udo=; b=DNfrgmHb+/tSTnKsRmsokgm73sTAdVXvkZgXz34hV0Dghpo22VT84+yTFWrF+w+fhI Z+noOIm3frHaSbrS7kTvoGPCkTnSEHnC37eJ/HPN9Wqstxns+lAnkWsannA7OyRzBGv/ feb/XEdBb+9dWy6/8j0CnkPLVLBMo/IhefxMoZubVTZFU0syY4/kSkr/Hy5ThZuOHbDi Vv13DlQ9bBvXVY/JYJb70nFCycJnoBqopHUwkAjJbtAVVZiIblKElQjQRqFFvYLHIIDk iJSeuUrj+astWtdPIbb2HVlHuWboRT1R7vLsMZT8c6M7X+beBsRTsnP0tKMZmMHpKygi apYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711037522; x=1711642322; 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=IQQWfLs/rkE7rpozeif9leaDk6Fe1YevxA9gj3J8Udo=; b=n49krh2uciLslrdX1jValBNo2HiSLEufSc640WoeRJGyXWGSAqPGbdPGaOgC52BZa3 joUIPKhOTsro9IjUIf8pyPxIPRV/yK58DRAMIM21mqujUTDw0VnQKPfYXLdNdwtcEbMC HFNQbw4LdbtX+9Bca95tMhyf0SufWPF2pju3f4SJZP7vj8B4RsEudWVndfEpCA1QG2oB R4JWwy/ldIL6uFpQI5vmvLLIbmh9UWYQhnfQ7D80JfKSu31NaUmFxr+bivoKZfa8sdbl Qy52e4kqhUaIjKLB7e7JVXEoDNhBuGh+5L0RpKsZIIMEtSYwHAWQJGNMW+YC7eKsr5zH f8LQ== X-Gm-Message-State: AOJu0YzLoH+VbBf2LKw/wsYXKJeuQEkYha+kjKidWvjmxl4MAS6ZfnKU gbxDgzwPRcHnG9/mmLwZFbo957V9If4FSzUBoDvGJhOZwFgaDR1xFgF0lREZamqonZ4P4GNU3Fm x X-Google-Smtp-Source: AGHT+IFVuxLcjExAE0xxCohJfWwETHocc9RBcs+WS4TnBUKS5SjT41A5XJM+9RgW5sgQz7QpLge5PQ== X-Received: by 2002:a05:6a00:1482:b0:6e6:98bf:7b62 with SMTP id v2-20020a056a00148200b006e698bf7b62mr2643493pfu.8.1711037521786; Thu, 21 Mar 2024 09:12:01 -0700 (PDT) Received: from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203]) by smtp.gmail.com with ESMTPSA id w62-20020a638241000000b005e485fbd455sm41815pgd.45.2024.03.21.09.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:12:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v10 07/10] eal: allow user to set default log stream before init Date: Thu, 21 Mar 2024 09:00:23 -0700 Message-ID: <20240321161146.340421-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240321161146.340421-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240321161146.340421-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 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 --- 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(+) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index cc0f66b2bc61..27934ca7e688 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -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"); } diff --git a/app/pdump/main.c b/app/pdump/main.c index a9205e130bb1..7b9ba68b1a14 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -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"); diff --git a/app/proc-info/main.c b/app/proc-info/main.c index b672aaefbe99..24ee52c4ac7a 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -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"); diff --git a/lib/log/log.c b/lib/log/log.c index 255f757d94cc..4cc944305057 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -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 */ diff --git a/lib/log/log_internal.h b/lib/log/log_internal.h index 451629f1c1ba..c77e687e28bc 100644 --- a/lib/log/log_internal.h +++ b/lib/log/log_internal.h @@ -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. diff --git a/lib/log/log_unix.c b/lib/log/log_unix.c index ae38b4bf3a59..c56f80ac6967 100644 --- a/lib/log/log_unix.c +++ b/lib/log/log_unix.c @@ -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; diff --git a/lib/log/version.map b/lib/log/version.map index 0648f8831aff..6ecc656d1d65 100644 --- a/lib/log/version.map +++ b/lib/log/version.map @@ -25,6 +25,7 @@ DPDK_24 { INTERNAL { global: + eal_log_get_default; eal_log_init; eal_log_level2str; eal_log_save_pattern; -- 2.43.0