doc: replace code blocks with includes in logging guide

Message ID 20240227142138.1942161-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series doc: replace code blocks with includes in logging guide |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

David Marchand Feb. 27, 2024, 2:21 p.m. UTC
  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 <david.marchand@redhat.com>
---
 doc/guides/prog_guide/log_lib.rst | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
  

Comments

David Marchand March 6, 2024, 9:10 p.m. UTC | #1
On Tue, Feb 27, 2024 at 3:22 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> 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 <david.marchand@redhat.com>

Applied.
  

Patch

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);