From patchwork Tue Oct 22 09:32:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 61638 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 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 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 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..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) return 0; } +FILE * +rte_log_get_stream(void) +{ + 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; + } + } + return 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) { + 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; };