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 7369642DCC; Tue, 4 Jul 2023 09:47:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 052DF40F18; Tue, 4 Jul 2023 09:47:02 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 75CD340E03 for ; Tue, 4 Jul 2023 09:47:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688456820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fG98SNEpi88oSf9szrIvH+byeAp+vcVi9tHNkqBByNM=; b=XmumZwb8IOW2MIHMxEbS9s4GOZaDbynBudH1YLFZTjffunhmYUhw4JMnjd1cuTtbizqkSr bn8xhR+hEz02Dm+oGcUhsMPmR5nqoDmR2yqo1xgcC5+5Cj14rKWjJyDBzUcWF86pu20vBH ogHKoyQteggm+TxdF2Q5kPqvAzxKbF0= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-lo-8kWluNPykgNEb9dSwjA-1; Tue, 04 Jul 2023 03:46:58 -0400 X-MC-Unique: lo-8kWluNPykgNEb9dSwjA-1 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-263036d4c9dso5285001a91.2 for ; Tue, 04 Jul 2023 00:46:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688456818; x=1691048818; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fG98SNEpi88oSf9szrIvH+byeAp+vcVi9tHNkqBByNM=; b=BZRucuWDHveJypFe99ANj8UgEauN6Gaw1jTxfZzdTL+ETmB3eYyzFIm6w8zuGW0nNp 7Tvuis2fBl49iMpycBBzdANQplNaGqz0Mgjrx4L1//74ZA5tsLEo2TcddJWWLp4KwpU1 nCNJBbm6OjumtE4B+YanpIGtzt6EYXo0K5oUO3RJYK2AfQEUP10lIkidbbE+h7bciyKD AgFz2qZ8ABVXctXyNCRRFrHRjXje1XLDJ1LEqlYwvMGeHVtLg/b/47W3mASQeugzm+8n UmlWJqviOrrQTBjx9QeBCjygA41P9Kp1xs3RZMnBsbu0dih77zGyOQIEUaGiyhPIOAgA n4Jw== X-Gm-Message-State: ABy/qLZAp5WNw8IiP3pv/7/A2Ins0eT+3SBoy8z+yzZtOaWLpV7xgeYa AA5ZkNHanEzsApomBIZSPs/KVBDllMywZ5dlx9zVEtzVKvc/7RhyVm3rOdHqioHMh9v9v3BjMDL WZ7nedg9rM5eJohsaJck= X-Received: by 2002:a17:90a:7b87:b0:263:8083:bdcf with SMTP id z7-20020a17090a7b8700b002638083bdcfmr9951787pjc.15.1688456817897; Tue, 04 Jul 2023 00:46:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlF3j+F5ZQVbAPsXOA1kTijIIP1y3DsGqbWdiIz9dT2oEgOQlYxE0ZUG+Em8Ldqodp7EjRZ4JTcCFJN5HQ6SSa0= X-Received: by 2002:a17:90a:7b87:b0:263:8083:bdcf with SMTP id z7-20020a17090a7b8700b002638083bdcfmr9951782pjc.15.1688456817564; Tue, 04 Jul 2023 00:46:57 -0700 (PDT) MIME-Version: 1.0 References: <20230613143355.77914-1-bruce.richardson@intel.com> <20230620170728.74117-1-bruce.richardson@intel.com> <20230620170728.74117-2-bruce.richardson@intel.com> In-Reply-To: <20230620170728.74117-2-bruce.richardson@intel.com> From: David Marchand Date: Tue, 4 Jul 2023 09:46:46 +0200 Message-ID: Subject: Re: [PATCH v2 1/2] doc/contributing: provide coding details for dynamic logging To: Bruce Richardson Cc: dev@dpdk.org, stephen@networkplumber.org, mb@smartsharesystems.com, ferruh.yigit@amd.com, jerinjacobk@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Jun 20, 2023 at 7:08=E2=80=AFPM Bruce Richardson wrote: > > 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 > --- > doc/guides/contributing/coding_style.rst | 17 +++++++++++++++++ > lib/cfgfile/rte_cfgfile.c | 2 ++ > 2 files changed, 19 insertions(+) > > diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contri= buting/coding_style.rst > index 89db6260cf..307c7deb9a 100644 > --- a/doc/guides/contributing/coding_style.rst > +++ b/doc/guides/contributing/coding_style.rst > @@ -803,6 +803,21 @@ logging of a particular topic, the ``--log-level`` p= arameter 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 topi= c. > > +To register a library or driver for dynamic logging, Nit: no need for a line break here, it can be fixed when applying. > +using the standardized naming scheme described below, > +use ``RTE_LOG_REGISTER_DEFAULT`` macro to define a log-type variable ins= ide your component's main C file. > +Thereafter, it is usual to define a macro or macros inside your componen= t 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 +852,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 ot= her 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 */ > -- > 2.39.2 > Thanks, this doc patch is a good addition in its current form. Reviewed-by: David Marchand Stephen used a little trick with a #define RTE_LOGTYPE_$type ${type}_logtype so that RTE_LOG() is directly usable. This makes conversion from static to dynamic logtypes rather easy. Example: https://patchwork.dpdk.org/project/dpdk/patch/20230329234049.11071= -5-stephen@networkplumber.org/ It could be something we advertise in this doc later. Maybe some consistency cleanup (and guidance) would be good too, as many components have close-yet-somewhat-different log formats (some log the function name, others write the line number etc...). --=20 David Marchand