From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04CB243B8A; Fri, 23 Feb 2024 00:46:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9167040EAB; Fri, 23 Feb 2024 00:46:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2188E402BD for ; Fri, 23 Feb 2024 00:46:48 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 58C6820B74C1; Thu, 22 Feb 2024 15:46:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 58C6820B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1708645607; bh=WLm8ngLLU+gjGYvJDbM2wFVMXPqKOSR6IQYSmPydxME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ayMZ9pPZbwTsUe2e8xQMsqrlp18d4CeyoNLXjaRka2HAglvKrKrKSDqiqL5wN4Ay5 CGiAJr75o4pU/L0kLj32cDMtpB2tQ8svN/TwJh3bL0Wa0Mu97rno7HMoU++dVAsa1u L+SBG/Oe94KU40ZIU9jzx3jLEijclagYul8v6Pv8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Anatoly Burakov , Ashish Gupta , Chenbo Xia , Cristian Dumitrescu , David Hunt , Fan Zhang , Hemant Agrawal , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Konstantin Ananyev , Maxime Coquelin , Reshma Pattan , Sachin Saxena , Sivaprasad Tummala , Srikanth Yalavarthi , Stephen Hemminger , Sunil Kumar Kori , bruce.richardson@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v2 01/17] log: add a per line log helper with parameterized prefix Date: Thu, 22 Feb 2024 15:46:30 -0800 Message-Id: <1708645606-7514-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1708645606-7514-1-git-send-email-roretzla@linux.microsoft.com> References: <1707774557-16012-1-git-send-email-roretzla@linux.microsoft.com> <1708645606-7514-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Providing a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from mlx5_common.h and provide RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with a custom prefix and argument list. Signed-off-by: Tyler Retzlaff --- lib/log/rte_log.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h index fbc0df7..a0fee24 100644 --- a/lib/log/rte_log.h +++ b/lib/log/rte_log.h @@ -379,6 +379,20 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +#define _RTE_LOG_COMMA , + +#define RTE_LOG_LINE_PREFIX(l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +#define RTE_LOG_DP_LINE_PREFIX(l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + #define RTE_LOG_REGISTER_IMPL(type, name, level) \ int type; \ RTE_INIT(__##type) \ -- 1.8.3.1