From patchwork Tue Jul 18 16:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 129633 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F62A42EAA; Tue, 18 Jul 2023 18:48:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D76F742D79; Tue, 18 Jul 2023 18:48:16 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 92D0342D74 for ; Tue, 18 Jul 2023 18:48:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689698894; x=1721234894; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/2ofA3JKfknlZtOK1GFQ/z+wuWoOPHhm8JuII5YUBMQ=; b=XnxdliaIlnbUZGNh3bPBEXvyMaYa0NC/NxDC4L+SFRLCTMsQqENVh3dY vrGuRMf+J80k7DL2L5vCK4Ygu/vmtcbKp9fHBNTXigXe+IDPusuJs0hso nUvLpCAmUhBkep9QExFmAxsLue7pPEKfdoULX4X4KDjTNn4t6n+O7ku2J 1A0YvkeDvTaqqzbWQjWqc60AUvBFJmxzeSp8ODJhmTELa/pSHynA79O++ 1SL49gjPl4Vg9gSunsL4yFVY7ne0Milax+ufzJOPDxI0cxsE63AElX+NG i7m2NusP3tm8SeoDp6MENhE9ax/HCHZf6PI2X02Z4sy3bYgvLSz4vMamO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="345848525" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="345848525" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 09:48:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="1054367359" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="1054367359" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.14]) by fmsmga005.fm.intel.com with ESMTP; 18 Jul 2023 09:48:12 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Chengwen Feng Subject: [PATCH v3 1/2] doc/contributing: provide coding details for dynamic logging Date: Tue, 18 Jul 2023 17:48:01 +0100 Message-Id: <20230718164802.110560-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230718164802.110560-1-bruce.richardson@intel.com> References: <20230613143355.77914-1-bruce.richardson@intel.com> <20230718164802.110560-1-bruce.richardson@intel.com> MIME-Version: 1.0 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 While the section on dynamic logging in the contributors guide covered the details of the logging naming scheme, it failed to cover exactly how the component developer, i.e. the contributor, could actually use dynamic logging in their component. Fix this by splitting the details of the naming scheme into a separate subsection, and adding to the introduction on logging, a recommendation (and example) to use RTE_LOG_REGISTER_DEFAULT. Similarly, when discussing specialization, include a reference to the RTE_LOG_REGISTER_SUFFIX macro. Signed-off-by: Bruce Richardson Acked-by: Chengwen Feng Reviewed-by: David Marchand Acked-by: Ferruh Yigit --- doc/guides/contributing/coding_style.rst | 16 ++++++++++++++++ lib/cfgfile/rte_cfgfile.c | 2 ++ 2 files changed, 18 insertions(+) diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst index 00d6270624..f41f88c632 100644 --- a/doc/guides/contributing/coding_style.rst +++ b/doc/guides/contributing/coding_style.rst @@ -803,6 +803,20 @@ logging of a particular topic, the ``--log-level`` parameter can be provided to EAL, which will change the log level. DPDK code can register topics, which allows the user to adjust the log verbosity for that specific topic. +To register a library or driver for dynamic logging, using the standardized naming scheme described below, +use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable inside your component's main C file. +Thereafter, it is usual to define a macro or macros inside your component to make logging more convenient. + +For example, the ``rte_cfgfile`` library defines: + +.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c + :language: c + :start-after: Setting up dynamic logging 8< + :end-before: >8 End of setting up dynamic logging + +Dynamic Logging Naming Scheme +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + In general, the naming scheme is as follows: ``type.section.name`` * Type is the type of component, where ``lib``, ``pmd``, ``bus`` and ``user`` @@ -837,6 +851,8 @@ A specialization looks like this: * Initialization output: ``type.section.name.init`` * PF/VF mailbox output: ``type.section.name.mbox`` +These specializations are created using the ``RTE_LOG_REGISTER_SUFFIX`` macro. + A real world example is the i40e poll mode driver which exposes two specializations, one for initialization ``pmd.net.i40e.init`` and the other for the remaining driver logs ``pmd.net.i40e.driver``. diff --git a/lib/cfgfile/rte_cfgfile.c b/lib/cfgfile/rte_cfgfile.c index 9fa7d010ef..eefba6e408 100644 --- a/lib/cfgfile/rte_cfgfile.c +++ b/lib/cfgfile/rte_cfgfile.c @@ -27,11 +27,13 @@ struct rte_cfgfile { struct rte_cfgfile_section *sections; }; +/* Setting up dynamic logging 8< */ RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO); #define CFG_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n", \ __func__, ## args) +/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries * for new sections do we add in */