[{"id":33781,"web_url":"https://patchwork.libcamera.org/comment/33781/","msgid":"<174343898969.3394313.18298351866268090218@ping.linuxembedded.co.uk>","date":"2025-03-31T16:36:29","subject":"Re: [PATCH 3/9] utils: gen-debug-controls: Improve log output","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-03-31 15:43:42)\n> Add log statements for found controls and the file written. This makes\n> it easier to understand what happens under the hood.\n> \n> While at it, create nice colored log out put using coloredlogs if\n> available.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/gen-debug-controls.py | 15 +++++++++++++--\n>  1 file changed, 13 insertions(+), 2 deletions(-)\n> \n> diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py\n> index ff22b986475e..a1c69bbd8294 100755\n> --- a/utils/gen-debug-controls.py\n> +++ b/utils/gen-debug-controls.py\n> @@ -17,8 +17,13 @@ import sys\n>  from dataclasses import dataclass\n>  from pathlib import Path\n>  \n> -logger = logging.getLogger(__name__)\n> -logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')\n> +fmt = '%(levelname)s: %(message)s'\n> +try:\n> +    import coloredlogs\n\nI see this is optional, I guess we don't need to document it as\nsomething to install as a developer dependency?\n\nAnyway, as you're currently the main user and developer of this file ...\n\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +    coloredlogs.install(level=logging.INFO, fmt=fmt)\n> +except ImportError:\n> +    logging.basicConfig(level=logging.INFO, format=fmt)\n> +\n>  \n>  try:\n>      import ruamel.yaml as ruyaml\n> @@ -27,6 +32,8 @@ except:\n>          f'Failed to import ruamel.yaml. Please install the ruamel.yaml package.')\n>      sys.exit(1)\n>  \n> +logger = logging.getLogger(__name__)\n> +\n>  @dataclass\n>  class FoundMatch:\n>      file: os.PathLike\n> @@ -106,6 +113,7 @@ def main(argv):\n>              continue\n>  \n>          p = m.file.relative_to(root_dir)\n> +        logger.info(f\"Found control {m.name} in {p}\")\n>          desc = {'type': m.type,\n>                  'direction': 'out',\n>                  'description': f'Debug control {m.name} found in {p}'}\n> @@ -165,6 +173,9 @@ def main(argv):\n>                   \"#\\n\"))\n>          yaml.dump(doc, f)\n>  \n> +    p = ctrl_file.relative_to(Path.cwd(), walk_up=True)\n> +    logger.info(f\"Sucessfully updated {p}\")\n> +\n>      return 0\n>  \n>  \n> -- \n> 2.43.0\n>","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 EEF21C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Mar 2025 16:36:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F8E468985;\n\tMon, 31 Mar 2025 18:36:34 +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 442AD68967\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Mar 2025 18:36:33 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B56A2725;\n\tMon, 31 Mar 2025 18:34:41 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"J9O8Amlh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743438881;\n\tbh=3LyoF98u5jD2TsWYTI2lQCPXqRHOo81gyySZFotFp7o=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=J9O8AmlhMSzBiF+RZ65IIK0YOj/At4xzGlOVCXKWLLmTFzKEt5MxEjWvv//61BH0r\n\tDfG83hHXr+FvT+Wve8Xj5hemfh6t27LJTZ/3dr3ALTlHkvaGLQK3qDRUanTGBfDq14\n\t92WyGlZ05pclrOmwn5954/sgnTiYVhbKwXTlrkp8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250331144352.736700-4-stefan.klug@ideasonboard.com>","References":"<20250331144352.736700-1-stefan.klug@ideasonboard.com>\n\t<20250331144352.736700-4-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH 3/9] utils: gen-debug-controls: Improve log output","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 31 Mar 2025 17:36:29 +0100","Message-ID":"<174343898969.3394313.18298351866268090218@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]