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 26E6743751; Thu, 21 Dec 2023 17:32:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0ADFA4026B; Thu, 21 Dec 2023 17:32:32 +0100 (CET) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id 92360400D6 for ; Thu, 21 Dec 2023 17:32:30 +0100 (CET) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6d77c6437f0so517182b3a.2 for ; Thu, 21 Dec 2023 08:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1703176349; x=1703781149; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=a+EF2C/gjzGlMVtrSA7B/jsLhCkEPnn1ZStOd/Z7uIk=; b=HqncangwLEtrnuzTOfYr/B2q6KOiHkVBPZlbBX6+cmPV1+Tc8u4lEZSKRozunaZliz dHhYkfC1WjQGx0LuiyUX6AJp3MDLLKM0zZfbBM+f8vgPt8+fYWEzdgaumzJvk6aGQnsq lOxCLFQT7EaDoO4f5aqtH4mgAMzoDa7JlqCuGpUBUDNm81M7sI+gD3cIWjbxXddazq8A o3OnIyhfgB8MFVzDgQjN4QdvcbH1zmerAjuGphLpCh/h7uTE3PiljIWhws2IgaeM2/Wf Bjc6acovhR2R9Nv/p4jgi03sqodbewTwAkxSAhhA9PPv6GA/Sj4gvcvPsMHA26jm1rbU arnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703176349; x=1703781149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a+EF2C/gjzGlMVtrSA7B/jsLhCkEPnn1ZStOd/Z7uIk=; b=fyCtTfFQX3Vp9Yp3Pwn284tUBfLRqioiWYZZOPftM/RqdYslpAhX2wpCWEQWpkFv1x kNdkFjnb/Uovk4mecBUnr5eJJMBAgyP0BXZn8lu1QdoTo0YSVVSjht5R+5uHeG+mAqOR tnwl1bWumjapRDRm59/2Zy5zGNo5/Xsqf74AFW9UCxee8NVnmIz18mP51+K6/j59/gUU ENlphIKIgY8mTwO6PEaTI6bBbTnDtQi2n38J3LGeKhCFTC9UHYNvEP7yDvZI3WTRlfab XcQ2lUpiAtIboUVxbzBz47utnuxtD7hxrbO2GZDv0bX7r6ot91IQueqmhyCiiNIHFFW0 zI0Q== X-Gm-Message-State: AOJu0Yy6cH3O1onDCTcLFErICgvGX6mbYKF4OdeQbXEsR3+pgvq022OY y3Q5qzYk4shRMm4IaPivHGH5HQ== X-Google-Smtp-Source: AGHT+IGLkeulYPU2INhOeLP6z7aXjVi3HtfF9o4brbwLvNAWrfPNjckcftEycqGjcpQC/U2W4Xr0rA== X-Received: by 2002:a05:6a00:889:b0:6d0:8898:11a8 with SMTP id q9-20020a056a00088900b006d0889811a8mr12716785pfj.40.1703176349632; Thu, 21 Dec 2023 08:32:29 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id fm22-20020a056a002f9600b006d96bb5db5esm1857701pfb.96.2023.12.21.08.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 08:32:28 -0800 (PST) Date: Thu, 21 Dec 2023 08:32:26 -0800 From: Stephen Hemminger To: David Marchand Cc: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@amd.com, bruce.richardson@intel.com, mb@smartsharesystems.com Subject: Re: [PATCH v5 00/13] Detect superfluous newline in logs Message-ID: <20231221083226.47f59795@hermes.local> In-Reply-To: <20231220153607.718606-1-david.marchand@redhat.com> References: <20231117131824.1977792-1-david.marchand@redhat.com> <20231220153607.718606-1-david.marchand@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Wed, 20 Dec 2023 16:35:53 +0100 David Marchand wrote: > Getting readable and consistent logs is important when running a DPDK > application, especially when troubleshooting. > A common issue with logs is when a DPDK change do not add (or on the > contrary add too many \n) in the format string. > > This issue would only get noticed when actually hitting this log (which > may be a situation hard to reach). > > This series proposes to introduce a new RTE_LOG_LINE helper that is > responsible for logging a one line message and spews a build error (with > gcc) if any \n is part of the format string. > > > Since the v1 discussion on the cover letter, I changed my mind, and made the > choice to break existing logging helpers exported in the public API. > The reasoning is that those should not be used in the first place: > logs should be produced only by the library that registers the logtype. > > Some multiline logging for debugging and the test assert macros are > still present, but in this case an explicit call to RTE_LOG() is done. > This can be checked with a simple: > $ git grep -E 'RTE_LOG(_DP)?\(' -- lib/ :^lib/log/ > lib/acl/acl_bld.c: RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n" > lib/acl/acl_gen.c: RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n" > lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF, "%s(%p) stats:\n" > lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF, > lib/eal/common/eal_common_debug.c: RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" > lib/eal/include/rte_test.h: RTE_LOG(ERR, EAL, "Test assert %s line %d failed: " \ > lib/ip_frag/ip_frag_common.h:#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) > lib/sched/rte_sched.c: RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n" > lib/sched/rte_sched.c: RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n" > lib/vhost/vhost.h: RTE_LOG_DP(DEBUG, VHOST_DATA, "VHOST_DATA: (%s) %s", dev->ifname, packet); \ Tabs are also problematic for syslog. With simple mod to testpmd: diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9e4e99e53b9a..811fe0c4aeb8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -4555,6 +4555,9 @@ main(int argc, char** argv) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", rte_strerror(rte_errno)); + RTE_LOG(INFO, USER1, "Sample log message with extra\nnewline\n"); + RTE_LOG(INFO, USER1, "Sample log message with tab\tinserted\n"); And the result in syslog is: 2023-12-21T08:27:47.172156-08:00 sut dpdk-testpmd[69471]: USER1: Sample log message with extra#012newline 2023-12-21T08:27:47.173418-08:00 sut dpdk-testpmd[69471]: USER1: Sample log message with tab#011inserted