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 DBA7142D8D; Thu, 29 Jun 2023 17:59:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32F9B42D3B; Thu, 29 Jun 2023 17:59:26 +0200 (CEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 2EEE142BFE for ; Thu, 29 Jun 2023 17:59:22 +0200 (CEST) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-66869feb7d1so551538b3a.3 for ; Thu, 29 Jun 2023 08:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688054361; x=1690646361; 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=2REMwfqBNFQRsvdAmxlcKkjoRSmPem4p2WHk4M7Y314=; b=fGmeOgAVCRnP/iMTJALcntq50GwM2USRxQUJ7yRH3DdwJeJliD6m1sYRtl/BnC/fdR Ws/aKeXsmqiF+dj2Xrfqm3GuqVJUT94GkDZ5tElicCMTdcqrLzgmB/v85967saq297+a 0Z3dE9v+nWR5DqNoc/UcDsrqCIjRVFDpcj7h1VajiJ5eEBxQRQHMilRhEuU3sbR1ySWg PIrM2BAK4wXWEGDJQLa7Znv+UKRk3+TdQTjOmbjelYRia/m+9gEtaLHciYNRcUiTrFE/ GeBgOXodukDLaf5riffXCWBA7TI9i4fsclF8+0hmLqMgBjHiaknE4eA4uvbLELXOE1SM hj2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688054361; x=1690646361; 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=2REMwfqBNFQRsvdAmxlcKkjoRSmPem4p2WHk4M7Y314=; b=TzGPGHidsH57maUSyIfxqVa96MWDpXjbf98VWEppRhmxlhwui9TGPrRlcqqGuZgsLV twpYU9Pg6UDmSl5UM7NWrea/8j4kwvNMEsBbqQgvtbwiew8GKMYCNs6bAR4vEyYTFsOO s8LDo3kKE6waW+MBg3XdNCFL3Xviccxx4pGN7KHLWMZwSmH69yK/bvOHqDJ4aaeoydSo FU4MpHAdynjPTWV49ijy8eAo2woaAu44iRy+C2aEjSOyA1oAWChjMUiOjq45rNC3krZE V27p3thIrup5op6Jg8EEJt3m6il/uTan4ktNklEwYKjcJ6fIauYGBpiS0U8tDr5S6WlZ 1A0A== X-Gm-Message-State: ABy/qLa7p+kucvMvoJLs0yHeaTf3lfzvv/mvkvv7lS4LarjMDFYZbC12 w0kWR6NLnJph+2A6LikipZqcV34Cl7IUbpn2vi+q9A== X-Google-Smtp-Source: APBJJlGHCVtUiA+/l5GLa4Xpo/5PynBq/owmG/M+XxW5G9hNtHycEOrR/c6gd6g7158+vYiAFrk/zQ== X-Received: by 2002:a62:1850:0:b0:67a:31b7:456c with SMTP id 77-20020a621850000000b0067a31b7456cmr363553pfy.9.1688054361144; Thu, 29 Jun 2023 08:59:21 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id c6-20020a63ea06000000b0055b553157a5sm471716pgi.71.2023.06.29.08.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 08:59:20 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan , Maryam Tahhan Subject: [PATCH v6 5/6] eal: allow user to set default log stream before init Date: Thu, 29 Jun 2023 08:58:42 -0700 Message-Id: <20230629155858.75668-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230629155858.75668-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20230629155858.75668-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/eal/common/eal_common_log.c | 6 ++++++ lib/eal/common/eal_log.h | 1 + lib/eal/unix/eal_log.c | 4 ++++ 6 files changed, 20 insertions(+) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index 64294bbfb3e6..bf31eef13cf4 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -639,6 +639,9 @@ static void dpdk_init(void) eal_argv[i++] = strdup(file_prefix); } + /* 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 c94606275b28..82c67350e4ab 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -989,6 +989,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 53e852a07c14..371b1f382d66 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -1774,6 +1774,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/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index ada3ed5ebec9..827830916eb7 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -584,6 +584,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/eal/common/eal_log.h b/lib/eal/common/eal_log.h index 31dc489350f6..268c2a264382 100644 --- a/lib/eal/common/eal_log.h +++ b/lib/eal/common/eal_log.h @@ -22,6 +22,7 @@ int eal_log_level_parse(int argc, char * const argv[]); * Determine where log data is written when no call to rte_openlog_stream. */ void eal_log_set_default(FILE *default_log); +FILE *eal_log_get_default(void); /* * Save a log option for later. diff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c index 151f30eb6071..98753cb52e09 100644 --- a/lib/eal/unix/eal_log.c +++ b/lib/eal/unix/eal_log.c @@ -60,6 +60,10 @@ eal_log_init(const char *id, int facility) { FILE *log_stream; + /* has 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; -- 2.39.2