Patch Detail
Show a patch.
GET /api/1.1/patches/22614/?format=api
{ "id": 22614, "url": "https://patchwork.libcamera.org/api/1.1/patches/22614/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22614/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250123090421.33226-1-stefan.klug@ideasonboard.com>", "date": "2025-01-23T09:04:18", "name": "[v3] libcamera: log: Match whole category in LIBCAMERA_LOG_LEVELS", "commit_ref": "9b1f609e5b754ce7adc0219a08b72714ae783e43", "pull_url": null, "state": "accepted", "archived": false, "hash": "d5ff428802bec5e89f562c8dda2a9dcfad1671f7", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22614/mbox/", "series": [ { "id": 4965, "url": "https://patchwork.libcamera.org/api/1.1/series/4965/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4965", "date": "2025-01-23T09:04:18", "name": "[v3] libcamera: log: Match whole category in LIBCAMERA_LOG_LEVELS", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4965/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22614/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22614/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1F527C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jan 2025 09:04:30 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC0596855D;\n\tThu, 23 Jan 2025 10:04:28 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D50436187B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2025 10:04:26 +0100 (CET)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:c0a:33cd:b453:5d3f])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2E0233A4;\n\tThu, 23 Jan 2025 10:03:23 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nLHwYdyh\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737623003;\n\tbh=5BNIWa/4ZUlWWfw6gpxfPA4juooPuNG4l1IwcyY/k00=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=nLHwYdyhTjkDajcIFU5pEnORz8ZAo8jDFlestyyV8l955itUNjQhp9HAupbwJjaUZ\n\tVNhPvLAMalBCmuwhSyM6I2DA3SrwcMJnxolPNyNXNSaO0z0Lq8p6rdTxz1vunUCIAj\n\tODHhm67VxUTpxrSshDuWyWKwGeTouMUNsvOyvoWs=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[PATCH v3] libcamera: log: Match whole category in\n\tLIBCAMERA_LOG_LEVELS", "Date": "Thu, 23 Jan 2025 10:04:18 +0100", "Message-ID": "<20250123090421.33226-1-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "A LIBCAMERA_LOG_LEVELS value of \"RkISP1:0\" also applies to RkISP1Ccm and\nRkISP1Awb. This behavior is unexpected as it automatically enables all\nalgorithm log categories when the intent is only to increase the log\nlevel of the upper category. Fix that replacing the manual matching code\nwith fnmatch. This has the side effect that more wildcards (\"?\" and\n\"[...]\") are supported which is acceptable but won't be advertised.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Replaced matching code with fnmatch instead of a manual fix\n\nChanges in v3:\n- Collected tag\n- Updated documentation to no longer restrict the wildcard to the end\n of the string\n---\n src/libcamera/base/log.cpp | 26 ++++++--------------------\n 1 file changed, 6 insertions(+), 20 deletions(-)", "diff": "diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 3a656b8f099f..72e0db859943 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -8,6 +8,7 @@\n #include <libcamera/base/log.h>\n \n #include <array>\n+#include <fnmatch.h>\n #include <fstream>\n #include <iostream>\n #include <list>\n@@ -38,8 +39,8 @@\n * The levels are configurable through the LIBCAMERA_LOG_LEVELS environment\n * variable that contains a comma-separated list of 'category:level' pairs.\n *\n- * The category names are strings and can include a wildcard ('*') character at\n- * the end to match multiple categories.\n+ * The category names are strings and can include a wildcard ('*') character to\n+ * match multiple categories.\n *\n * The level are either numeric values, or strings containing the log level\n * name. The available log levels are DEBUG, INFO, WARN, ERROR and FATAL. Log\n@@ -717,24 +718,9 @@ void Logger::registerCategory(LogCategory *category)\n \tcategories_.push_back(category);\n \n \tconst std::string &name = category->name();\n-\tfor (const std::pair<std::string, LogSeverity> &level : levels_) {\n-\t\tbool match = true;\n-\n-\t\tfor (unsigned int i = 0; i < level.first.size(); ++i) {\n-\t\t\tif (level.first[i] == '*')\n-\t\t\t\tbreak;\n-\n-\t\t\tif (i >= name.size() ||\n-\t\t\t name[i] != level.first[i]) {\n-\t\t\t\tmatch = false;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t}\n-\n-\t\tif (match) {\n-\t\t\tcategory->setSeverity(level.second);\n-\t\t\tbreak;\n-\t\t}\n+\tfor (const auto &[pattern, severity] : levels_) {\n+\t\tif (fnmatch(pattern.c_str(), name.c_str(), FNM_NOESCAPE) == 0)\n+\t\t\tcategory->setSeverity(severity);\n \t}\n }\n \n", "prefixes": [ "v3" ] }