Show a patch.

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

{
    "id": 11922,
    "url": "https://patchwork.libcamera.org/api/patches/11922/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11922/",
    "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": "<20210413215121.15538-2-laurent.pinchart@ideasonboard.com>",
    "date": "2021-04-13T21:51:20",
    "name": "[libcamera-devel,1/2] libcamera: log: De-duplicate _log() functions and LogMessage constructor",
    "commit_ref": "93be96431a5cdacfe632c3cfb6763b90649bc590",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e41c6958543ef3ffe5e397a64ae9af3224861b9c",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11922/mbox/",
    "series": [
        {
            "id": 1924,
            "url": "https://patchwork.libcamera.org/api/series/1924/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1924",
            "date": "2021-04-13T21:51:19",
            "name": "libcamera: log: Small improvements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1924/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11922/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11922/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 A9E49BD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Apr 2021 21:52:18 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A803602D1;\n\tTue, 13 Apr 2021 23:52:18 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D30A602D1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 23:52:16 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F2E019F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 23:52:15 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KFXcGCYu\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618350736;\n\tbh=PdEjLeBIcQmJ4Ym3GKto2J0Z86/U0EyyE6QQ5cAAu3s=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=KFXcGCYuCcj5jz+D1dgAIiZ3qbeTKrhfZwlX52+jm/9a4XclvYsjDfbcopa+HEg55\n\tCWxsgjznrswt9AeJUSOWx+HKAOabcPCR6kMSZwl2pMWdpk+sTQCZryy8wOZ/9hpzlP\n\tjH/0/eNPsXV11zeJFxZ2I7BeBI3PIrM0B37B+rNo=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 14 Apr 2021 00:51:20 +0300",
        "Message-Id": "<20210413215121.15538-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.28.1",
        "In-Reply-To": "<20210413215121.15538-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210413215121.15538-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: log: De-duplicate _log()\n\tfunctions and LogMessage constructor",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The _log() functions, as well as the LogMessage constructor, exist in\ntwo versions, one that takes a log category, and one that doesn't. The\nlatter uses the default log category. This can be simplied by passing a\nLogCategory pointer to _log(), which can then be null for the default\ncategory, and moving the retrieval of the default log category from the\nLogMessage constructor to the _log() function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/log.h | 13 ++-----\n src/libcamera/log.cpp            | 66 ++++----------------------------\n 2 files changed, 12 insertions(+), 67 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h\nindex e76ae913c857..0fdacc4733fe 100644\n--- a/include/libcamera/internal/log.h\n+++ b/include/libcamera/internal/log.h\n@@ -55,8 +55,6 @@ const LogCategory &_LOG_CATEGORY(name)()\t\t\t\t\\\n class LogMessage\n {\n public:\n-\tLogMessage(const char *fileName, unsigned int line,\n-\t\t   LogSeverity severity);\n \tLogMessage(const char *fileName, unsigned int line,\n \t\t   const LogCategory &category, LogSeverity severity);\n \n@@ -92,23 +90,20 @@ protected:\n \tvirtual std::string logPrefix() const = 0;\n \n \tLogMessage _log(const char *file, unsigned int line,\n-\t\t\tLogSeverity severity) const;\n-\tLogMessage _log(const char *file, unsigned int line,\n-\t\t\tconst LogCategory &category,\n+\t\t\tconst LogCategory *category,\n \t\t\tLogSeverity severity) const;\n };\n \n-LogMessage _log(const char *file, unsigned int line, LogSeverity severity);\n LogMessage _log(const char *file, unsigned int line,\n-\t\tconst LogCategory &category, LogSeverity severity);\n+\t\tconst LogCategory *category, LogSeverity severity);\n \n #ifndef __DOXYGEN__\n #define _LOG_CATEGORY(name) logCategory##name\n \n #define _LOG1(severity) \\\n-\t_log(__FILE__, __LINE__, Log##severity).stream()\n+\t_log(__FILE__, __LINE__, nullptr, Log##severity).stream()\n #define _LOG2(category, severity) \\\n-\t_log(__FILE__, __LINE__, _LOG_CATEGORY(category)(), Log##severity).stream()\n+\t_log(__FILE__, __LINE__, &_LOG_CATEGORY(category)(), Log##severity).stream()\n \n /*\n  * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of\ndiff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp\nindex 45c7c2d24652..9f86e645ac58 100644\n--- a/src/libcamera/log.cpp\n+++ b/src/libcamera/log.cpp\n@@ -763,24 +763,6 @@ const LogCategory &LogCategory::defaultCategory()\n  * directly. Use the LOG() macro instead access the log infrastructure.\n  */\n \n-/**\n- * \\brief Construct a log message for the default category\n- * \\param[in] fileName The file name where the message is logged from\n- * \\param[in] line The line number where the message is logged from\n- * \\param[in] severity The log message severity, controlling how the message\n- * will be displayed\n- *\n- * Create a log message pertaining to line \\a line of file \\a fileName. The\n- * \\a severity argument sets the message severity to control whether it will be\n- * output or dropped.\n- */\n-LogMessage::LogMessage(const char *fileName, unsigned int line,\n-\t\t       LogSeverity severity)\n-\t: category_(LogCategory::defaultCategory()), severity_(severity)\n-{\n-\tinit(fileName, line);\n-}\n-\n /**\n  * \\brief Construct a log message for a given category\n  * \\param[in] fileName The file name where the message is logged from\n@@ -913,26 +895,6 @@ Loggable::~Loggable()\n  * \\return A string to be prefixed to the log message\n  */\n \n-/**\n- * \\brief Create a temporary LogMessage object to log a message\n- * \\param[in] fileName The file name where the message is logged from\n- * \\param[in] line The line number where the message is logged from\n- * \\param[in] severity The log message severity\n- *\n- * This method is used as a backeng by the LOG() macro to create a log message\n- * for locations inheriting from the Loggable class.\n- *\n- * \\return A log message\n- */\n-LogMessage Loggable::_log(const char *fileName, unsigned int line,\n-\t\t\t  LogSeverity severity) const\n-{\n-\tLogMessage msg(fileName, line, severity);\n-\n-\tmsg.stream() << logPrefix() << \": \";\n-\treturn msg;\n-}\n-\n /**\n  * \\brief Create a temporary LogMessage object to log a message\n  * \\param[in] fileName The file name where the message is logged from\n@@ -946,31 +908,17 @@ LogMessage Loggable::_log(const char *fileName, unsigned int line,\n  * \\return A log message\n  */\n LogMessage Loggable::_log(const char *fileName, unsigned int line,\n-\t\t\t  const LogCategory &category,\n+\t\t\t  const LogCategory *category,\n \t\t\t  LogSeverity severity) const\n {\n-\tLogMessage msg(fileName, line, category, severity);\n+\tLogMessage msg(fileName, line,\n+\t\t       category ? *category : LogCategory::defaultCategory(),\n+\t\t       severity);\n \n \tmsg.stream() << logPrefix() << \": \";\n \treturn msg;\n }\n \n-/**\n- * \\brief Create a temporary LogMessage object to log a message\n- * \\param[in] fileName The file name where the message is logged from\n- * \\param[in] line The line number where the message is logged from\n- * \\param[in] severity The log message severity\n- *\n- * This function is used as a backeng by the LOG() macro to create a log\n- * message for locations not inheriting from the Loggable class.\n- *\n- * \\return A log message\n- */\n-LogMessage _log(const char *fileName, unsigned int line, LogSeverity severity)\n-{\n-\treturn LogMessage(fileName, line, severity);\n-}\n-\n /**\n  * \\brief Create a temporary LogMessage object to log a message\n  * \\param[in] fileName The file name where the message is logged from\n@@ -984,9 +932,11 @@ LogMessage _log(const char *fileName, unsigned int line, LogSeverity severity)\n  * \\return A log message\n  */\n LogMessage _log(const char *fileName, unsigned int line,\n-\t\tconst LogCategory &category, LogSeverity severity)\n+\t\tconst LogCategory *category, LogSeverity severity)\n {\n-\treturn LogMessage(fileName, line, category, severity);\n+\treturn LogMessage(fileName, line,\n+\t\t\t  category ? *category : LogCategory::defaultCategory(),\n+\t\t\t  severity);\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}