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 B6059A04A5; Wed, 17 Jun 2020 08:30:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A8B5A5F2F; Wed, 17 Jun 2020 08:30:22 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id A3DCF4F9C for ; Wed, 17 Jun 2020 08:30:20 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05H6TxL1010750; Tue, 16 Jun 2020 23:30:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=6fRqqxC7223if7Dh3hL4KIojhcdJU/6K2U52iWqfE20=; b=XL34KrBJ7Uf5fR22azYPsYWZLpCXV89U+lHDNg+SBipMIm3xmuA9ynXVG5/ZQBjQLVwt 99rcMPKBF3NlUMtwJLdjJnkUVgCXXGDoOlyKSlsfYEp10YiW/TXD8qf+hXg7kBq/BJUq KkgrX1Dmb88qOiDz/aD+Bn1LNHtmDCjxC2DrljcAWmak/kmPgKC5RjBPexJKEy0L8AJE CkXDAPYnhYr5Ugi39ZLdYad938khfEvTViqkS8IP61LL4ADk4J2dqS/LF33k6wvBg2Eu zD9myNhyvrCx7NiZ/V5h5bVOcHXHcTUYmU0QVlYH/9oqsGW5oPtMXht3ZhrJN8g0wZkt mw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 31q676jkfy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 16 Jun 2020 23:30:18 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Jun 2020 23:30:18 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 16 Jun 2020 23:30:18 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id B35B13F7041; Tue, 16 Jun 2020 23:30:16 -0700 (PDT) From: To: CC: , , , Jerin Jacob Date: Wed, 17 Jun 2020 12:00:35 +0530 Message-ID: <20200617063047.1555518-2-jerinj@marvell.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617063047.1555518-1-jerinj@marvell.com> References: <20200617063047.1555518-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-16_13:2020-06-16, 2020-06-16 signatures=0 Subject: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro 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" From: Jerin Jacob Introducing the RTE_LOG_REGISTER macro to avoid the code duplication in the log registration process. It is a wrapper macro for declaring the logtype, register the log and sets it's level in the constructor context. Signed-off-by: Jerin Jacob --- lib/librte_eal/include/rte_log.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h index 1789ede56..4dc357074 100644 --- a/lib/librte_eal/include/rte_log.h +++ b/lib/librte_eal/include/rte_log.h @@ -376,6 +376,31 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ 0) +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Register a dynamic log type in constructor context with its name and level. + * + * It is a wrapper macro for declaring the logtype, register the log and sets + * it's level in the constructor context. + * + * @param type + * The log type identifier + * @param name + * Name for the log type to be registered + * @param level + * Log level. A value between EMERG (1) and DEBUG (8). + */ +#define RTE_LOG_REGISTER(type, name, level) \ +int type; \ +RTE_INIT(__##type) \ +{ \ + type = rte_log_register(RTE_STR(name)); \ + if (type >= 0) \ + rte_log_set_level(type, RTE_LOG_##level); \ +} + #ifdef __cplusplus } #endif -- 2.26.2