Show a patch.

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

{
    "id": 17905,
    "url": "https://patchwork.libcamera.org/api/patches/17905/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17905/",
    "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": "<20221129053326.2858347-4-paul.elder@ideasonboard.com>",
    "date": "2022-11-29T05:33:26",
    "name": "[libcamera-devel,3/3] utils: libtuning: Add logging parameters to argparse",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "dd57557b6d4f3ee4e4930d7f895e67f089350dd6",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17905/mbox/",
    "series": [
        {
            "id": 3645,
            "url": "https://patchwork.libcamera.org/api/series/3645/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3645",
            "date": "2022-11-29T05:33:23",
            "name": "utils: tuning: Add logging infrastructure",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3645/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17905/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17905/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 9C7F0BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Nov 2022 05:33:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DDCDD6333F;\n\tTue, 29 Nov 2022 06:33:43 +0100 (CET)",
            "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 A810A63334\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Nov 2022 06:33:41 +0100 (CET)",
            "from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77C9E4E6;\n\tTue, 29 Nov 2022 06:33:40 +0100 (CET)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669700023;\n\tbh=86DQt6YHZKxFRsOn+dGB7Nmhmi3E0D7IfPCUkr8iS4g=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HsIG+eZfmT0jDHPWhKcGv89uKhIbOlFNM2IPyN3euLw2QrOKfGtHt4rMLv+GMaDKK\n\tRgX24kLnk9aDglcKCudqt3gXayjXjEfWap0LbZh6bXd3zZy/GZWQs5OgEn8fDlVmzs\n\tXSnFSo+xu82xh/WRYxC+oKKNhm+BVYys4bTVG2o9AORyNW9Yunp6pcJeITC8f32twC\n\tYgOQRrghi1J71pk/JzJzrnRayFbQSscAcf7CpbIAYnW3MSZ8GHAzoemLeZqHzlhmxm\n\t+7WXEnRc6q8he4x433HmIG6PZ7iIDETDj5GVnNYif2ZvoFlsWtM1ActXQ3AxpoVBC1\n\tM+g84TrWdQuEA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669700021;\n\tbh=86DQt6YHZKxFRsOn+dGB7Nmhmi3E0D7IfPCUkr8iS4g=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BDv4KKytPlWg+SrjLy+Hc8K2O0lQshRmERCytxUrdD51Y4xo2LRMiOk/0xPqsjj6o\n\t/M9kxqAerm8wpEf7qCuALhwJjolnlFqtHGONSHVa6+O6dc7uOJilSsm2jD1pN17xIc\n\taMVSDJE7YDVWotdd30aR3J8zDC1sO5ueSrZj9yCQ="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BDv4KKyt\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 29 Nov 2022 14:33:26 +0900",
        "Message-Id": "<20221129053326.2858347-4-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20221129053326.2858347-1-paul.elder@ideasonboard.com>",
        "References": "<20221129053326.2858347-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 3/3] utils: libtuning: Add logging\n\tparameters to argparse",
        "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>",
        "From": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add command line arguments for log levels and log output file.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n utils/tuning/libtuning/libtuning.py | 32 +++++++++++++++++++++++++----\n 1 file changed, 28 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py\nindex d34d98ab..b2c40ba4 100644\n--- a/utils/tuning/libtuning/libtuning.py\n+++ b/utils/tuning/libtuning/libtuning.py\n@@ -6,6 +6,7 @@\n \n import argparse\n from pathlib import Path\n+import sys\n \n import libtuning as lt\n from libtuning.logger import Logger\n@@ -150,10 +151,24 @@ class Tuner(object):\n         # options, so simply return an empty configuration if none is provided.\n         parser.add_argument('-c', '--config', type=str, default='',\n                             help='Config file (optional)')\n-        # \\todo Check if we really need this or if stderr is good enough, or if\n-        # we want a better logging infrastructure with log levels\n-        parser.add_argument('-l', '--log', type=str, default=None,\n-                            help='Output log file (optional)')\n+        parser.add_argument('-l', '--log', type=str, default=sys.stderr,\n+                            help='Output log file (optional). Default is stderr.')\n+        parser.add_argument('-ll', '--log_levels', type=str, default='',\n+                            help='''Output log levels (optional).\n+                                    A comma-separated list of module names and\n+                                    their log levels (in integer form, where\n+                                    debug=0, info=1, warn=2, error=3, and\n+                                    fatal=4), in the format: \"{module name}:{log\n+                                    level},{module name}:{log_level}...\", and so\n+                                    on. Any module that is not specified will use the\n+                                    default log level, or the default can be\n+                                    specified with the log name \"*\". For the\n+                                    purposes of logging, module names are the\n+                                    same as class names, or the file name for\n+                                    components that are not classes. This\n+                                    parameter can also be simply set to a\n+                                    single integer to set the log levels for\n+                                    all components.''')\n         parser.add_argument('-dd', '--debug_dir', type=str, default=None,\n                             help='''Debug output directory (optional).\n                                     If the directory does not exist, it will be\n@@ -205,6 +220,12 @@ class Tuner(object):\n             if not debug_dir.is_dir():\n                 debug_dir.mkdir()\n \n+        # Prepare logging\n+        if args.log is not sys.stderr:\n+            Logger.log_file = open(args.log, mode='a')\n+\n+        Logger.set_log_levels(args.log_levels)\n+\n         # Validate modules and set debug\n         for module in self.modules:\n             if not module.validate_config(self.config):\n@@ -237,4 +258,7 @@ class Tuner(object):\n \n         self.generator.write(args.output, self.output, self.output_order)\n \n+        if Logger.log_file is not sys.stderr:\n+            Logger.log_file.close()\n+\n         return 0\n",
    "prefixes": [
        "libcamera-devel",
        "3/3"
    ]
}