Show a patch.

GET /api/patches/25847/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 25847,
    "url": "https://patchwork.libcamera.org/api/patches/25847/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25847/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20260119113104.3560802-3-barnabas.pocze@ideasonboard.com>",
    "date": "2026-01-19T11:31:00",
    "name": "[v2,2/5] libcamera: base: log: Do not instantiate disabled `LogMessage`s",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "644e5c764e219694ff7e812cc7811e9b151d3707",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25847/mbox/",
    "series": [
        {
            "id": 5716,
            "url": "https://patchwork.libcamera.org/api/series/5716/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5716",
            "date": "2026-01-19T11:30:58",
            "name": "libcamera: base: log: Do not instantiate disabled `LogMessage`s",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5716/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25847/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25847/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 D4EFEC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jan 2026 11:31:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B39F861FC6;\n\tMon, 19 Jan 2026 12:31:10 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3787961FB9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 12:31:08 +0100 (CET)",
            "from pb-laptop.local (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B6728C79\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 12:30:37 +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=\"aGG5poCg\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768822237;\n\tbh=emvrmnnI4/cToii6BSjuUIOwHrDklh9jfJ5ZFeVMMdo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=aGG5poCgpTCFE2f9YITw3QM6OmsrlA8a7sbsYpEh7oPHTGl3zhibvdWMx6AR7lPKA\n\t+XvCJOjkLKF6CbIBPWwq/Cq2DP0r6DxH+FMKAzhfDsYCRShRyo51NFvGRa9H8qMGk+\n\t1odfw46yQMBnLBLFiart0CTgxPu0zmPzhwi/qi/k=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v2 2/5] libcamera: base: log: Do not instantiate disabled\n\t`LogMessage`s",
        "Date": "Mon, 19 Jan 2026 12:31:00 +0100",
        "Message-ID": "<20260119113104.3560802-3-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260119113104.3560802-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20260119113104.3560802-1-barnabas.pocze@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "At the moment every `LOG()` macro invocation results in a `LogMessage` being\ncreated, the message serialized into an `std::stringstream`. Only in the\ndestructor is it actually checked whether the given `LogCategory` enables\nthe given log level.\n\nThis is not too efficient, it would be better to skip the log message\nconstruction and all the `operator<<()` invocations if the message will\njust be discarded.\n\nThis could be easily done if the `LOG()` macro accepted its arguments like a\ntraditional function as in that case an appropriate `if` statement can be\ninjected in a do-while loop. However, that is not the case, the `LOG()` macro\nshould effectively \"return\" a stream.\n\nIt is not possible inject an `if` statement directly as that would\nlead to issues:\n\n  if (...)\n    LOG(...)\n  else\n   ...\n\nThe `else` would bind the to the `if` in the `LOG()` macro. This is\ndiagnosed by `-Wdangling-else`.\n\nAn alternative approach would be to use a `for` loop and force a single\niteration using a boolean flag or similar. This is entirely doable but\nI think the implemented approach is easier to understand.\n\nThis change implements the early log level checking using a `switch` statement\nas this avoids the dangling else related issues. One small issue arises\nbecause having a boolean controlling expression is diagnosed by clang\n(`-Wswitch-bool`); the result is cast to `int` to avoid the warning.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/base/log.h | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\nindex d8338d8df..dbd14951c 100644\n--- a/include/libcamera/base/log.h\n+++ b/include/libcamera/base/log.h\n@@ -108,10 +108,15 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n #ifndef __DOXYGEN__\n #define _LOG_CATEGORY(name) logCategory##name\n \n+#define _LOG(cat, sev) \\\n+\tswitch (const auto &_logCategory = (cat); int(_logCategory.severity() <= Log##sev)) \\\n+\tcase 1: \\\n+\t\t_log(_logCategory, Log##sev).stream()\n+\n #define _LOG1(severity) \\\n-\t_log(LogCategory::defaultCategory(), Log##severity).stream()\n+\t_LOG(LogCategory::defaultCategory(), severity)\n #define _LOG2(category, severity) \\\n-\t_log(_LOG_CATEGORY(category)(), Log##severity).stream()\n+\t_LOG(_LOG_CATEGORY(category)(), severity)\n \n /*\n  * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of\n",
    "prefixes": [
        "v2",
        "2/5"
    ]
}