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 8262EA32A4 for ; Fri, 25 Oct 2019 21:06:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2697F1E558; Fri, 25 Oct 2019 21:06:20 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id DCD611E53F for ; Fri, 25 Oct 2019 21:06:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572030378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5C3qk39+c/LW/E9OZDljXhS1cRfaLckR4uRCo3rXHkk=; b=QwgcSJo3vtaHC+UNCi8Ub6BhKlvPTJSNbL5/aRwAvVS3bGEvp/QuUYJt5X1+CGwIFXHJ0M 4lW8h3blv8+ZUCUUY7DgIdOI+ft5opHZuL93VJELT2Pt+niRSY+bSY51zfWYg8aO8FZDTV 7YjK8n3NykUDFyqK2xfnLTbkD4wRMJs= 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-420-igwsF4EoPqyCHZsEW6QSVg-1; Fri, 25 Oct 2019 15:06:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 271755E4; Fri, 25 Oct 2019 19:06:14 +0000 (UTC) Received: from [10.36.118.52] (unknown [10.36.118.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 829D95D9CA; Fri, 25 Oct 2019 19:05:55 +0000 (UTC) To: David Marchand , dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net, John Griffin , Fiona Trahe , Deepak Kumar Jain References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1572011772-23271-1-git-send-email-david.marchand@redhat.com> <1572011772-23271-8-git-send-email-david.marchand@redhat.com> From: Kevin Traynor Message-ID: Date: Fri, 25 Oct 2019 20:05:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <1572011772-23271-8-git-send-email-david.marchand@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: igwsF4EoPqyCHZsEW6QSVg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [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" On 25/10/2019 14:56, David Marchand wrote: > 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. >=20 > Signed-off-by: David Marchand > Acked-by: Thomas Monjalon > --- > Changelog since v1: > - use ternary operator, >=20 > --- > 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(-) >=20 > 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= char *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 b= e sent > - * to the stream defined by rte_logs.file or to stderr in case of rte_lo= gs.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/comm= on/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 a= p) > { > +=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/com= mon/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_strea= m() > + * 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_= version.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 Acked-by: Kevin Traynor