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 3BEF3A328D for ; Tue, 22 Oct 2019 11:35:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 781451BEB3; Tue, 22 Oct 2019 11:35:10 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 517A61BE98 for ; Tue, 22 Oct 2019 11:35:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571736906; 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=QGKZ65n9H4ZrNi2ydvKcg6X6kT42ybe5q71WVqfkh4k=; b=HK2+HVF7qLxBhh7rwPAy6lWwUAgdOkjtTmPK30AJN32KKMlxPEZ8JNDXZV6iJR1ZLvBKH0 ZWZ9vbwudGneJrwTQhgOSNDwerMp9xSPxbreimipT64IyM6taaKg2aGautPaHDlO4M/9Xe U9wRH7MrSsoHmzGJOI1OgAcJZMn3QgU= 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-277-wpWlxGZ6Od222kebNAjN7A-1; Tue, 22 Oct 2019 05:33:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBBB4800D53; Tue, 22 Oct 2019 09:33:18 +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 142CB6012D; Tue, 22 Oct 2019 09:33:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, anatoly.burakov@intel.com, thomas@monjalon.net, John Griffin , Fiona Trahe , Deepak Kumar Jain Date: Tue, 22 Oct 2019 11:32:40 +0200 Message-Id: <1571736761-32134-8-git-send-email-david.marchand@redhat.com> In-Reply-To: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: wpWlxGZ6Od222kebNAjN7A-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH 7/8] 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 --- drivers/common/qat/qat_logs.c | 3 +-- drivers/common/qat/qat_logs.h | 3 +-- lib/librte_eal/common/eal_common_log.c | 36 ++++++++++++++++++++---------= ---- lib/librte_eal/common/include/rte_log.h | 13 ++++++++++++ lib/librte_eal/rte_eal_version.map | 3 +++ 5 files changed, 40 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..cfe9599 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -71,6 +71,27 @@ 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=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} +=09return f; +} + /* Set global log level */ void rte_log_set_global_level(uint32_t level) @@ -396,21 +417,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