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 E94B843CEE; Mon, 18 Mar 2024 23:05:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F56540DCA; Mon, 18 Mar 2024 23:04:52 +0100 (CET) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 2CE1E40A71 for ; Mon, 18 Mar 2024 23:04:49 +0100 (CET) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e6f69e850bso3763932b3a.0 for ; Mon, 18 Mar 2024 15:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710799488; x=1711404288; 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=T8d4wbz8UaPAWAX98FuZk1eIKsZOb9m1Xynp/hHjNCo=; b=1x/DuWghv5zagI5s20Zm6IN6OtnuyeygY7vN68iVRoMd1GlHiSUWchg76hndVJnRLE zHS8IrgdM+DiILK4OzMj9lW8Vmp7pN10KDYWV1xRLE07kdA24u7aXPsf7TsAAvuOc8Ni FwVBKhPhzX5Qft0wyhWTQMVfPP8egM0rHJk/C1/dqMLdiY8xOOkTkH47UQfeyJbsy9Q6 fDe0AUav31NWYt6qh7pH9L6D+5dAE2DdyTDgozQtq5b4zO1xi3cC2aCOz4fUWmxA85ay dycpWT0K4XSSmKlAymgjSx1gMEX2G7roW1M1NK5nUF0zFnRs2K9z6+fAoaUxlE3xMEfx vSLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710799488; x=1711404288; 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=T8d4wbz8UaPAWAX98FuZk1eIKsZOb9m1Xynp/hHjNCo=; b=dpHqdEt0UjwMCo9wT1/F+LRs39Z/RRiw4owtSh5n4rvKVoWzhl7a/lh+PGkOb5n2A1 As1dq3niUk83uDUKC8xevTcgylMqwLHQfbshGROjcSQoy8Y4wyrGd/EmeQPVf87Tnlyi zYUn91a/VbolXQbSrMpQgO48RuFY5bQ36ZdxXKpj5xp9M1F5hUfFCiNna11cWjpvsmjS PWUEYnsuJar2Ehmo3L39h/HrLChHkqZlpqg9o4W90jmWoo4ytLLyrJMOFaABJZ5romoP l9k9ezTpZNCq/trj82TGXMRiA2RzhfEj/cUMck+s3s2y8xD2UntYRbxClhY+L86WWQvn zVlg== X-Gm-Message-State: AOJu0YyrdkAyGDuZCA51ZsOYCuHjWjHkFqfHo0EYEZku0Z8sQwBViHoO sY8ll4GizrVQLNEzArrczec6iTUZkb89v3F1Y5q1DNdEy20JW6/nJtpU2Bh1S9l3RMoJOj8o9uh I X-Google-Smtp-Source: AGHT+IHG4Sg5ew3IOWoFgdgPzXGv/CoxE8pRwzr8RcTilVYewTptGB7DjmnK7bOf+9N5xWX5QgS75Q== X-Received: by 2002:a05:6a20:a111:b0:1a3:677c:23c1 with SMTP id q17-20020a056a20a11100b001a3677c23c1mr4583748pzk.12.1710799488349; Mon, 18 Mar 2024 15:04:48 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y6-20020a637d06000000b005dc88b232a5sm7747140pgc.26.2024.03.18.15.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 15:04:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v9 4/5] eal: allow user to set default log stream before init Date: Mon, 18 Mar 2024 15:03:00 -0700 Message-ID: <20240318220432.7486-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240318220432.7486-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20240318220432.7486-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 2dfb0c974b1d..a415bae5774d 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