From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BDDC8A32A4 for ; Fri, 25 Oct 2019 15:58:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A1A611C2FA; Fri, 25 Oct 2019 15:57:19 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 495541C2A1 for ; Fri, 25 Oct 2019 15:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WfYec7StGzV6PWp9nHP0HmW/ZLXKuz8Wru2z9XzeFb4=; b=eb4MT4ErJW3xeBVbMiEJgIdscWdVat4yXNIhseJpXZYCxEfVFtaaZ/H+Z7hVqvUKQgKkWW cXc/8SbUasua1krM3w8Pca/xWbm5TCGaUn+VMKKxiNosG81b8IST+dWR419sP/ppePaWX0 Mq0gFWNboh1PK3HS9GXONW0oV/cJrrE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-cbuArZDYNF6FuA6DsK3H5Q-1; Fri, 25 Oct 2019 09:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 106331005500; Fri, 25 Oct 2019 13:56:56 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-129.brq.redhat.com [10.40.204.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D04310013A1; Fri, 25 Oct 2019 13:56:53 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net, ktraynor@redhat.com, John Griffin , Fiona Trahe , Deepak Kumar Jain Date: Fri, 25 Oct 2019 15:56:06 +0200 Message-Id: <1572011772-23271-8-git-send-email-david.marchand@redhat.com> In-Reply-To: <1572011772-23271-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1572011772-23271-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: cbuArZDYNF6FuA6DsK3H5Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v3 07/12] log: add log stream accessor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Define an accessor so that users can write their debug message to the same stream than the rte_log infrastructure. Use it in the qat infrastructure. Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- Changelog since v1: - use ternary operator, --- drivers/common/qat/qat_logs.c | 3 +-- drivers/common/qat/qat_logs.h | 3 +-- lib/librte_eal/common/eal_common_log.c | 33 +++++++++++++++++++----------= ---- lib/librte_eal/common/include/rte_log.h | 13 +++++++++++++ lib/librte_eal/rte_eal_version.map | 3 +++ 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c index 7a86170..f97aba1 100644 --- a/drivers/common/qat/qat_logs.c +++ b/drivers/common/qat/qat_logs.c @@ -19,8 +19,7 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const c= har *title, =09if (level > (uint32_t)(rte_log_get_level(logtype))) =09=09return 0; =20 -=09rte_hexdump(rte_logs.file =3D=3D NULL ? stderr : rte_logs.file, -=09=09=09=09title, buf, len); +=09rte_hexdump(rte_log_get_stream(), title, buf, len); =09return 0; } =20 diff --git a/drivers/common/qat/qat_logs.h b/drivers/common/qat/qat_logs.h index 4baea12..2e4d394 100644 --- a/drivers/common/qat/qat_logs.h +++ b/drivers/common/qat/qat_logs.h @@ -24,8 +24,7 @@ extern int qat_dp_logtype; * * Dump out the message buffer in a special hex dump output format with * characters printed for each line of 16 hex values. The message will be = sent - * to the stream defined by rte_logs.file or to stderr in case of rte_logs= .file - * is undefined. + * to the stream used by the rte_log infrastructure. */ int qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title, diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common= /eal_common_log.c index 4f6f227..e0a7bef 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -71,6 +71,24 @@ rte_openlog_stream(FILE *f) =09return 0; } =20 +FILE * +rte_log_get_stream(void) +{ +=09FILE *f =3D rte_logs.file; + +=09if (f =3D=3D NULL) { +=09=09/* +=09=09 * Grab the current value of stderr here, rather than +=09=09 * just initializing default_log_stream to stderr. This +=09=09 * ensures that we will always use the current value +=09=09 * of stderr, even if the application closes and +=09=09 * reopens it. +=09=09 */ +=09=09return default_log_stream ? : stderr; +=09} +=09return f; +} + /* Set global log level */ void rte_log_set_global_level(uint32_t level) @@ -396,21 +414,8 @@ rte_log_dump(FILE *f) int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) { +=09FILE *f =3D rte_log_get_stream(); =09int ret; -=09FILE *f =3D rte_logs.file; -=09if (f =3D=3D NULL) { -=09=09f =3D default_log_stream; -=09=09if (f =3D=3D NULL) { -=09=09=09/* -=09=09=09 * Grab the current value of stderr here, rather than -=09=09=09 * just initializing default_log_stream to stderr. This -=09=09=09 * ensures that we will always use the current value -=09=09=09 * of stderr, even if the application closes and -=09=09=09 * reopens it. -=09=09=09 */ -=09=09=09f =3D stderr; -=09=09} -=09} =20 =09if (level > rte_logs.level) =09=09return 0; diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/commo= n/include/rte_log.h index cbb4184..1bb0e66 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -102,6 +102,19 @@ extern struct rte_logs rte_logs; int rte_openlog_stream(FILE *f); =20 /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Retrieve the stream used by the logging system (see rte_openlog_stream(= ) + * to change it). + * + * @return + * Pointer to the stream. + */ +__rte_experimental +FILE *rte_log_get_stream(void); + +/** * Set the global log level. * * After this call, logs with a level lower or equal than the level diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_ve= rsion.map index 0887549..6d7e0e4 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -417,4 +417,7 @@ EXPERIMENTAL { =09rte_mcfg_timer_lock; =09rte_mcfg_timer_unlock; =09rte_rand_max; + +=09# added in 19.11 +=09rte_log_get_stream; }; --=20 1.8.3.1