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 96A6242DDE; Thu, 6 Jul 2023 00:48:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8EB4E42D61; Thu, 6 Jul 2023 00:48:16 +0200 (CEST) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id E252042D5A for ; Thu, 6 Jul 2023 00:48:13 +0200 (CEST) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-262e3c597b9so133272a91.0 for ; Wed, 05 Jul 2023 15:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688597293; x=1691189293; 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=tu64yanKVd/U/fBF/GuU00+xQ7H4v2dyUbNhKOpsKv0=; b=2sSn+bI+aTKE1RKQinc1Rb4B+XushAbPGSJ15OpLpzVhGDJvG5pbiVmKl6/+q2UzXk 5BZvOrQuQ9usl9+vOIJ7/sxD6CzjLijK+ac0jqmcGYMLe6O3bEmBnFVJc7VBeVl4VimU UasBu5GoMXbiWk7/UDTBojHn6mozH2+UlsYSQWWuAfB2bNNhPYC4XgoL2ZfuroqS/vIC b9TAXt6RtcdyOv3m2GGB0DmIVqdarUzldzjwWIzIiw7KBimFJtxoRn/dbn6y8ti3hFr8 xmnNPHj+bTkI5aR++J7UV0UM6XQy6GdxrBIotrmpym06eQb6TVvUwRNDFTfVHcklUcQq IdoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688597293; x=1691189293; 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=tu64yanKVd/U/fBF/GuU00+xQ7H4v2dyUbNhKOpsKv0=; b=VycgAkxAGksnDRkiIN2xJ7JaFWFgBshz+rqeZ/N33tZb8BQsRVk+dIJGFPsKIHmvXs lXGDkt2sXInMl1pE6qh1rxT6b1qiyRZKfBuTdijbTFaiGNhBeiaZPUY8RqLJ4R8LSRmR QBQKOle05OJLwvka5QvSgU4763oyjji0bTcqeu8r/h1PydfyMZgEnuqdfVu77xyoS2O6 Wat4VqUetOmihF+GfXQ5pj01zlNhGRX55BDC2TP3vLJkRAO/5zn8LiBFXom/gUptEOMk 0gor3ju/+86Rg2g3R8CkTaxhox6dLfXsLrbZ7C8yCddCNnO4XVWaZHFxDzsDe5L+LG82 oA5Q== X-Gm-Message-State: ABy/qLZ7A1LFccml/Wv6JpG1X33CuFJePQZ9tjNvfYjm42iO29yvdmTU 3uITKiO27IrUlfMxWVtBvDhxqyvJqcEuJrY4o3Y= X-Google-Smtp-Source: APBJJlGZiDJYF+L7r+KzjTZIj01D1Gh+sR3kfxr6o5g/MMnI3MMiiW+9E1Zdr/5sjYCT6+3UC5n+Aw== X-Received: by 2002:a17:90a:ac0d:b0:261:38ca:3c48 with SMTP id o13-20020a17090aac0d00b0026138ca3c48mr150843pjq.11.1688597292798; Wed, 05 Jul 2023 15:48:12 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id bb16-20020a17090b009000b002630bfd35b0sm1906044pjb.7.2023.07.05.15.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 15:48:12 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan , Maryam Tahhan Subject: [PATCH v7 4/5] eal: allow user to set default log stream before init Date: Wed, 5 Jul 2023 15:48:04 -0700 Message-Id: <20230705224805.286156-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230705224805.286156-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20230705224805.286156-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 1b2080e8ef04..1533ee871f47 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 85d817c2d31e..e66bcc68d07f 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