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 8545C42D82; Wed, 28 Jun 2023 19:59:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46E0442D3F; Wed, 28 Jun 2023 19:58:41 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 4B0FB42BFE for ; Wed, 28 Jun 2023 19:58:37 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1b7f223994fso1493205ad.3 for ; Wed, 28 Jun 2023 10:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1687975116; x=1690567116; 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=nE2jNT5rnryaJFXWUIFUABW5PA5MQ6/vAjoD8y7GhEI=; b=P6wxS6gVH7NYrgIvhlKyUOPZwg4DDg0JDCIos70AzaoLQhJFh3LbYofhq2BjQM6SGr J5l7u+q6B8aT4X0KY2DUHNFSPmqDGiC9whPCej+V6XFeoTtGCzfUTtK8WRWbajxVwhkZ sO0x9Mjso/wVzr1PN1yBOSUNSdkJlfy8DG1cWcbMrN2UiMnRzBOrP/OBYJZR4gB5y25b W64Y/lsi5J+0PMzNEG6MxGR40WjCzkmt/H5fjsWKnUmoSfL7ksaixQ1kYNmQs9fcKO1Q XmwLbyYtC3VpI7MDY9jdgX50Rx0BDEw9xa5+w79AU9+0GIWrqOKegxFceyy7zXtdNg2y tVJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687975116; x=1690567116; 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=nE2jNT5rnryaJFXWUIFUABW5PA5MQ6/vAjoD8y7GhEI=; b=WyZN0lh+Wc/qGriU4pIdr/Gq0gdnA16n/cH9FeQ7JF5HkYvL/Uz5VT/3JeY5VLmnTW 45R0fR8lLsVjSYgodiAVmobSyt3mEJ/WCCvTnAO+U/3CsroV+Iz/Ya2/kcmabnr4w26V B9odsfjhHYAKX2lp9RuRh7ezdHzoZoJOE8p/U2iu2xBzhSFcW/lg7ho4brrhWV3CYgNx EF8dS9PdXcU2rgbvvFG12ja0kqY7lW2Y5VFv4o9il8mz4HUl9NB7K4EvAw53ae2KRZdq PV2gPIOKQPuHozqrRSyK01A7dP3Bacnl6Xc5Ydc7BUFmm4ePvD6VpZvPlPJo/XiS8Ajq R68w== X-Gm-Message-State: AC+VfDyAQSepct/G0jqdQ7EDmI6yisKtcj8iSgJC1Z/3YgCO6a3yIf3O kbxOF4Ro/CITNNspMRZa9GwMCe81fLs/AeNC7zthbg== X-Google-Smtp-Source: ACHHUZ4/b+Ki77np1aGegy6SJ5KDgJKGEQ/ggA/kprEd92fwKi0PajQ5afTdP4SRlGhMz/FoAVrwQQ== X-Received: by 2002:a17:903:1105:b0:1b6:6985:ff8d with SMTP id n5-20020a170903110500b001b66985ff8dmr17351492plh.42.1687975116298; Wed, 28 Jun 2023 10:58:36 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id g11-20020a170902868b00b001b80d399730sm5047875plo.242.2023.06.28.10.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 10:58:34 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v5 5/6] eal: allow user to set default log stream before init Date: Wed, 28 Jun 2023 10:58:26 -0700 Message-Id: <20230628175827.471909-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230628175827.471909-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20230628175827.471909-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_log_set_default(stderr); Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 6 ++++++ lib/eal/common/eal_log.h | 1 + lib/eal/unix/eal_log.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..9b158c201205 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -535,6 +535,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 7921417b050a..3bfe5853095f 100644 --- a/lib/eal/unix/eal_log.c +++ b/lib/eal/unix/eal_log.c @@ -113,6 +113,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