From patchwork Tue Feb 27 14:21:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 137356 X-Patchwork-Delegate: david.marchand@redhat.com 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 D601C43BF2; Tue, 27 Feb 2024 15:21:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A34F40151; Tue, 27 Feb 2024 15:21:52 +0100 (CET) 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 825054027D for ; Tue, 27 Feb 2024 15:21:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709043710; 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; bh=wb3vmUbPZpMeKlLF0/QKuC9/TLHLOrEWxjuOcTkoor0=; b=RPHEGQ3jEWxClm+GTqOfi0zfX4ZdTIlc0Lhu7Y3UKIY13apJF3heX+PoyCjwc+mQLBrYs3 0gS5VUCSHa63+72eV64j7j5LVTtVqNiPDcK0HjCyAFRWb/SqhprrpvAmIR3IB/FfNuCcaJ USyd0faKllQuLEpD9tIc21qDj42jlm8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-1mLRtnMxP6aYVRhfwrbPlA-1; Tue, 27 Feb 2024 09:21:48 -0500 X-MC-Unique: 1mLRtnMxP6aYVRhfwrbPlA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC7C4862CC7; Tue, 27 Feb 2024 14:21:47 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03146200A382; Tue, 27 Feb 2024 14:21:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: roretzla@linux.microsoft.com, Chengwen Feng , Andrew Rybchenko Subject: [PATCH] doc: replace code blocks with includes in logging guide Date: Tue, 27 Feb 2024 15:21:38 +0100 Message-ID: <20240227142138.1942161-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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 Rather than have a block of code as example that gets unaligned as time passes, add literal includes. The coding style guide points at the cfgfile library, let's use it too as an example. Fixes: 97433132c2ed ("lib: use per line logging in helpers") Signed-off-by: David Marchand --- doc/guides/prog_guide/log_lib.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst index 19e295fc9b..ff9d1b54a2 100644 --- a/doc/guides/prog_guide/log_lib.rst +++ b/doc/guides/prog_guide/log_lib.rst @@ -82,16 +82,14 @@ They do this by: * Using the log-level definitions given in ``rte_log.h`` to allow short textual names to be used in place of the numeric log levels. -The following code is taken from ``rte_dmadev.c`` and shows the log registration, +The following code is taken from ``rte_cfgfile.c`` and shows the log registration, and subsequent definition of a shortcut logging macro. It can be used as a template for any new components using DPDK logging. -.. code:: C - - RTE_LOG_REGISTER_DEFAULT(rte_dma_logtype, INFO); - #define RTE_DMA_LOG(level, ...) \ - rte_log(RTE_LOG_ ## level, rte_dma_logtype, RTE_FMT("dma: " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", RTE_FMT_TAIL(__VA_ARGS__,))) +.. literalinclude:: ../../../lib/cfgfile/rte_cfgfile.c + :language: c + :start-after: Setting up dynamic logging 8< + :end-before: >8 End of setting up dynamic logging .. note:: @@ -104,10 +102,11 @@ It can be used as a template for any new components using DPDK logging. and the logtype should be defined as an "extern int" in a common header file. Any component-specific logging macro should similarly be defined in that header. -Throughout the dmadev library, all logging calls are therefore of the form: +Throughout the cfgfile library, all logging calls are therefore of the form: .. code:: C - RTE_DMA_LOG(ERR, "Name can't be NULL"); + CFG_LOG(ERR, "missing cfgfile parameters"); - RTE_DMA_LOG(WARNING, "Device %d already started", dev_id); + CFG_LOG(ERR, "invalid comment characters %c", + params->comment_character);