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 DFD7743CE8; Mon, 18 Mar 2024 19:33:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBAE7406BA; Mon, 18 Mar 2024 19:32:51 +0100 (CET) Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by mails.dpdk.org (Postfix) with ESMTP id 435034068E for ; Mon, 18 Mar 2024 19:32:47 +0100 (CET) Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c36f882372so2784894b6e.2 for ; Mon, 18 Mar 2024 11:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710786766; x=1711391566; 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=1zvT9yoUij2iTIpCIkxlG7tMR3b6oO9O8DmBQqU6QU+V2lC70Zr2clta3c1zsRjrdF BN0L7bDdg7fCSSqv9xq0fXSv+Vl1SENXrQqjmF0MZaKJ6ISm9Gpv5hqRqS0W7nZegNRR vcD8DvfukUfo/iCoRJIQfysE07B3o3Qj+pptWI/etiwFFh4A9EX78guFvo61fy+gIyC7 qwj+MK1nzgEmXRWoJlzLFrNqrHStl/2K58/WluFANYvOjMmtcwAsBbIhmjLE8gPLnO6T QjjErU9aGRVwEI8BO5wl73/UzbZhnMcAJkg76OJAGHy0WM0y9unzEapSpEXjWRKNoy/B 1qvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710786766; x=1711391566; 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=N9cL5pLzRxotaGIKRBAAkBRuAQjXwu6mXurx/mpL8LSZNoQHxGEypeYBDCZJaiFtQC /sE1Jf+2ElqRR1Z+Bo9Y1nAFVQWHVA1HQkCH/Qlu8uFq5HhcRTIEzlU7Y1bSm4bIqrKq 2FBdwnslj559ckGl0bRquwDeaWQWRzmR45D6N/qH+dswRHNGvdOjVct9x6CQWJvyj0aC XgIcmVKkhOtq3SfY4VDskcGUa+MxyTnX6t0ISe3T+NhIN6GWm4K71v1eCEIE6vmE2PYh y4kKoz8/PQNiv360+KPt7LYQi2Ts1MD8tq5pXO4xoEr+gthSpnKxscVW/mQDUGYiRdMA W13g== X-Gm-Message-State: AOJu0Yx7SezZW1fHTrGYLI6uPb5Vsnmyjv8gJB8vRkDCt1sv8K2AmzrI GTdo/GfC9HHlMIzCVOAqYHtLwKoFhaavsyU4rvv5ewcc8O/R3E4aEBmlMKoPpuC2hRzXcK284zG p X-Google-Smtp-Source: AGHT+IH3DdFj1CfRK61NakMoFGaOT7Cmx4WIlq353GccR+8jc8XIwGJr83I7aHR4CNPYYC3lMr0dhg== X-Received: by 2002:a05:6358:528c:b0:17e:a952:2c00 with SMTP id g12-20020a056358528c00b0017ea9522c00mr529398rwa.4.1710786766473; Mon, 18 Mar 2024 11:32:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:32:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v8 3/5] eal: allow user to set default log stream before init Date: Mon, 18 Mar 2024 11:30:04 -0700 Message-ID: <20240318183233.142330-4-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 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