From patchwork Wed Oct 23 18:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 61788 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78F8C1D405; Wed, 23 Oct 2019 20:55:10 +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 818601D3F0 for ; Wed, 23 Oct 2019 20:55:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571856905; 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=fhuZ/dmzGU6ozq8EsbDDsl/au8BbdzwYW6rIvmt7+fw=; b=Wt7qrTawxHEUjnKJSr8L5zvXW8q6FBEHxlEG0y6QpZHabaUR7qzqYQjsyZVfNA2y4CYQvn DVq5u35P549XG8aKvJMl9xAHJewJ5Jib4WGy3NvVCfqtQexBEeVICPc/ArnjvkYmoqi6wH MiYiSs2Jex1lMQ6WXSysbP7KtJ3yJA4= 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-75-UhXUAmV0OJaaDLqG-MpeEA-1; Wed, 23 Oct 2019 14:55:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A84181800D6B; Wed, 23 Oct 2019 18:55:00 +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 6166960872; Wed, 23 Oct 2019 18:54:58 +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: Wed, 23 Oct 2019 20:54:19 +0200 Message-Id: <1571856864-8779-8-git-send-email-david.marchand@redhat.com> In-Reply-To: <1571856864-8779-1-git-send-email-david.marchand@redhat.com> References: <1571736761-32134-1-git-send-email-david.marchand@redhat.com> <1571856864-8779-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: UhXUAmV0OJaaDLqG-MpeEA-1 X-Mimecast-Spam-Score: 0 Subject: [dpdk-dev] [PATCH v2 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 --- 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 char *title, if (level > (uint32_t)(rte_log_get_level(logtype))) return 0; - rte_hexdump(rte_logs.file == NULL ? stderr : rte_logs.file, - title, buf, len); + rte_hexdump(rte_log_get_stream(), title, buf, len); return 0; } 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) return 0; } +FILE * +rte_log_get_stream(void) +{ + FILE *f = rte_logs.file; + + if (f == NULL) { + /* + * Grab the current value of stderr here, rather than + * just initializing default_log_stream to stderr. This + * ensures that we will always use the current value + * of stderr, even if the application closes and + * reopens it. + */ + return default_log_stream ? : stderr; + } + return 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) { + FILE *f = rte_log_get_stream(); int ret; - FILE *f = rte_logs.file; - if (f == NULL) { - f = default_log_stream; - if (f == NULL) { - /* - * Grab the current value of stderr here, rather than - * just initializing default_log_stream to stderr. This - * ensures that we will always use the current value - * of stderr, even if the application closes and - * reopens it. - */ - f = stderr; - } - } if (level > rte_logs.level) return 0; diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/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); /** + * @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_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 { rte_mcfg_timer_lock; rte_mcfg_timer_unlock; rte_rand_max; + + # added in 19.11 + rte_log_get_stream; };