[PATCH v10 08/10] eal: add option to put timestamp on console output
Tyler Retzlaff
roretzla at linux.microsoft.com
Thu Mar 21 18:11:31 CET 2024
On Thu, Mar 21, 2024 at 09:00:24AM -0700, Stephen Hemminger wrote:
> When debugging driver or startup issues, it is useful to have
> a timestamp on each message printed. The messages in syslog
> already have a timestamp, but often syslog is not available
> during testing.
>
> There are multiple timestamp formats similar to Linux dmesg.
> The default is time relative since startup. Other alternatives
> are delta, ctime, reltime and iso formats.
>
> Example:
> $ dpdk-testpmd --log-timestamp -- -i
> EAL: Detected CPU lcores: 8
> EAL: Detected NUMA nodes: 1
> [ 0.000083] EAL: Detected static linkage of DPDK
> [ 0.002000] EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
> [ 0.003507] EAL: Selected IOVA mode 'VA'
> [ 0.006272] testpmd: No probed ethernet devices
> Interactive-mode selected
> [ 0.029567] testpmd: create a new mbuf pool <mb_pool_0>: n=203456, size=2176, socket=0
> [ 0.029588] testpmd: preferred mempool ops selected: ring_mp_mc
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> app/test/test_eal_flags.c | 17 ++++
> doc/guides/prog_guide/log_lib.rst | 10 ++
> lib/eal/common/eal_common_options.c | 14 ++-
> lib/eal/common/eal_options.h | 2 +
> lib/log/log_internal.h | 9 ++
> lib/log/log_unix.c | 152 +++++++++++++++++++++++++++-
> lib/log/log_windows.c | 6 ++
> lib/log/version.map | 1 +
> 8 files changed, 205 insertions(+), 6 deletions(-)
>
> diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
> index 6cb4b0675730..eeb1799381d7 100644
> --- a/app/test/test_eal_flags.c
> +++ b/app/test/test_eal_flags.c
> @@ -1055,6 +1055,14 @@ test_misc_flags(void)
> const char * const argv22[] = {prgname, prefix, mp_flag,
> "--huge-worker-stack=512"};
>
> + /* Try running with --log-timestamp */
> + const char * const argv23[] = {prgname, prefix, mp_flag,
> + "--log-timestamp" };
> +
> + /* Try running with --log-timestamp=iso */
> + const char * const argv24[] = {prgname, prefix, mp_flag,
> + "--log-timestamp=iso" };
> +
> /* run all tests also applicable to FreeBSD first */
>
> if (launch_proc(argv0) == 0) {
> @@ -1162,6 +1170,15 @@ test_misc_flags(void)
> printf("Error - process did not run ok with --huge-worker-stack=size parameter\n");
> goto fail;
> }
> + if (launch_proc(argv23) != 0) {
> + printf("Error - process did not run ok with --log-timestamp parameter\n");
> + goto fail;
> + }
> + if (launch_proc(argv24) != 0) {
> + printf("Error - process did not run ok with --log-timestamp=iso parameter\n");
> + goto fail;
> + }
> +
>
> rmdir(hugepath_dir3);
> rmdir(hugepath_dir2);
> diff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst
> index aacb36c36ce0..1d6b2e3cea5d 100644
> --- a/doc/guides/prog_guide/log_lib.rst
> +++ b/doc/guides/prog_guide/log_lib.rst
> @@ -73,6 +73,16 @@ For example::
> /path/to/app --syslog local0
>
>
> +Console timestamp
> +~~~~~~~~~~~~~~~~~
> +
> +On Linux and FreeBSD, an optional timestamp can be added before each
> +message by adding the ``--log-timestamp`` option.
i don't think Windows should be excluded from the feature, in general
core libraries that get features should cover all platforms.
More information about the dev
mailing list