From patchwork Mon Jan 20 13:30:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22585 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CF544C327D for ; Mon, 20 Jan 2025 13:30:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE2DE6854B; Mon, 20 Jan 2025 14:30:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CW/FNviE"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53F3960354 for ; Mon, 20 Jan 2025 14:30:46 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:4375:4b53:c7c1:47a6]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD6AA2E0; Mon, 20 Jan 2025 14:29:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737379784; bh=s5lV/uDSLTP+XHBveD+g0XZqof1Qj9O+ihT9clxu4mo=; h=From:To:Cc:Subject:Date:From; b=CW/FNviEoKzEWDr0Ioag0MwIQ17wQzd/l9y8f2o+Ngfyf91FwEtytMNdxn7R5oUdE Kij7V1GnOXi8TD8ehRF63391ZXbOKZs1JitZ/1PCtYmmQlcv5YZ/XGVDbGBCwr6RMX E+zTDULYIau1f3K9NHtaTdbA25GVjpqGrg//Mpvk= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] libcamera: log: Match whole category in LIBCAMERA_LOG_LEVELS Date: Mon, 20 Jan 2025 14:30:15 +0100 Message-ID: <20250120133038.817550-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A LIBCAMERA_LOG_LEVELS value of "RkISP1:0" also applies to RkISP1Ccm and RkISP1Awb. This behavior is unexpected as it automatically enables all algorithm log categories when the intent is only to increase the log level of the upper category. Fix that by ensuring that the full name gets matched. The * wildcard is still supported, so RkISP1* matches RkISP1 and RkISP1Awb. Signed-off-by: Stefan Klug --- src/libcamera/base/log.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 3a656b8f099f..36e57d6017ab 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -718,11 +718,15 @@ void Logger::registerCategory(LogCategory *category) const std::string &name = category->name(); for (const std::pair &level : levels_) { + unsigned int i; + bool wildcard = false; bool match = true; - for (unsigned int i = 0; i < level.first.size(); ++i) { - if (level.first[i] == '*') + for (i = 0; i < level.first.size(); ++i) { + if (level.first[i] == '*') { + wildcard = true; break; + } if (i >= name.size() || name[i] != level.first[i]) { @@ -731,6 +735,10 @@ void Logger::registerCategory(LogCategory *category) } } + /* Ensure the full name got matched */ + if (!(wildcard || i == name.size())) + continue; + if (match) { category->setSeverity(level.second); break;