[{"id":14727,"web_url":"https://patchwork.libcamera.org/comment/14727/","msgid":"<YAv3PY55e41hNF07@pendragon.ideasonboard.com>","date":"2021-01-23T11:15:25","subject":"Re: [libcamera-devel] [PATCH 1/5] ipa: raspberrypi: controller:\n\tReplace Raspberry Pi debug with libcamera debug","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Fri, Jan 22, 2021 at 10:22:07AM +0000, David Plowman wrote:\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/controller/controller.cpp | 29 +++++++++++--------\n>  1 file changed, 17 insertions(+), 12 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp\n> index 22461cc4..f81707c2 100644\n> --- a/src/ipa/raspberrypi/controller/controller.cpp\n> +++ b/src/ipa/raspberrypi/controller/controller.cpp\n> @@ -5,6 +5,8 @@\n>   * controller.cpp - ISP controller\n>   */\n>  \n> +#include \"libcamera/internal/log.h\"\n> +\n>  #include \"algorithm.hpp\"\n>  #include \"controller.hpp\"\n>  \n> @@ -12,6 +14,9 @@\n>  #include <boost/property_tree/ptree.hpp>\n>  \n>  using namespace RPiController;\n> +using namespace libcamera;\n\nI wonder if the controllers should be moved to the libcamera namespace\n(to be precise, I mean making RPiController a sub-namespace of\nlibcamera). Not something to address in this series in any case.\n\n> +\n> +LOG_DEFINE_CATEGORY(RPiController)\n\nI've been toying with the idea of creating hierarchical logging\ncategories. This could become\n\nLOG_DEFINE_CATEGORY(RPi.Controller)\n\n(or something similar). We can already enable categories using wildcards\n(e.g. LIBCAMERA_LOG_LEVELS=RPi*:0), but creating categories with\nexplicit prefixes would force us to think about the best way to group\ncategories. Would this be useful ? It's not a high priority on my todo\nlist in any case.\n\nAnother idea I've been toying with is adding a main() function to\nlibcamera.so, in order to print information when invoking the shared\nlibrary as an executable. This would include the list of available\ncategories. Same question, useful or not ?\n\n>  Controller::Controller()\n>  \t: switch_mode_called_(false) {}\n> @@ -27,7 +32,7 @@ Controller::~Controller() {}\n>  \n>  void Controller::Read(char const *filename)\n>  {\n> -\tRPI_LOG(\"Controller starting\");\n> +\tLOG(RPiController, Debug) << \"Controller starting\";\n\nWe usually refrain from using debug messages that just trace the code,\nbut we don't have a drop-in replacement for this (there's a tracing\ninfrastructure, but that's for a different purpose). Have you found\nthese particular debug messages useful ?\n\n>  \tboost::property_tree::ptree root;\n>  \tboost::property_tree::read_json(filename, root);\n>  \tfor (auto const &key_and_value : root) {\n> @@ -36,10 +41,10 @@ void Controller::Read(char const *filename)\n>  \t\t\talgo->Read(key_and_value.second);\n>  \t\t\talgorithms_.push_back(AlgorithmPtr(algo));\n>  \t\t} else\n> -\t\t\tRPI_LOG(\"WARNING: No algorithm found for \\\"\"\n> -\t\t\t\t<< key_and_value.first << \"\\\"\");\n> +\t\t\tLOG(RPiController, Debug) << \"WARNING: No algorithm found for \\\"\"\n> +\t\t\t\t\t\t  << key_and_value.first << \"\\\"\";\n\nIf it's a warning, about about using the Warning log level, and dropping\nthe \"WARNING: \" prefix ?\n\n>  \t}\n> -\tRPI_LOG(\"Controller finished\");\n> +\tLOG(RPiController, Debug) << \"Controller finished\";\n>  }\n>  \n>  Algorithm *Controller::CreateAlgorithm(char const *name)\n> @@ -50,39 +55,39 @@ Algorithm *Controller::CreateAlgorithm(char const *name)\n>  \n>  void Controller::Initialise()\n>  {\n> -\tRPI_LOG(\"Controller starting\");\n> +\tLOG(RPiController, Debug) << \"Controller starting\";\n>  \tfor (auto &algo : algorithms_)\n>  \t\talgo->Initialise();\n> -\tRPI_LOG(\"Controller finished\");\n> +\tLOG(RPiController, Debug) << \"Controller finished\";\n>  }\n>  \n>  void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata)\n>  {\n> -\tRPI_LOG(\"Controller starting\");\n> +\tLOG(RPiController, Debug) << \"Controller starting\";\n>  \tfor (auto &algo : algorithms_)\n>  \t\talgo->SwitchMode(camera_mode, metadata);\n>  \tswitch_mode_called_ = true;\n> -\tRPI_LOG(\"Controller finished\");\n> +\tLOG(RPiController, Debug) << \"Controller finished\";\n>  }\n>  \n>  void Controller::Prepare(Metadata *image_metadata)\n>  {\n> -\tRPI_LOG(\"Controller::Prepare starting\");\n> +\tLOG(RPiController, Debug) << \"Controller::Prepare starting\";\n\nShould the previous three functions also mention the function name ?\n\n>  \tassert(switch_mode_called_);\n>  \tfor (auto &algo : algorithms_)\n>  \t\tif (!algo->IsPaused())\n>  \t\t\talgo->Prepare(image_metadata);\n> -\tRPI_LOG(\"Controller::Prepare finished\");\n> +\tLOG(RPiController, Debug) << \"Controller::Prepare finished\";\n>  }\n>  \n>  void Controller::Process(StatisticsPtr stats, Metadata *image_metadata)\n>  {\n> -\tRPI_LOG(\"Controller::Process starting\");\n> +\tLOG(RPiController, Debug) << \"Controller::Process starting\";\n>  \tassert(switch_mode_called_);\n>  \tfor (auto &algo : algorithms_)\n>  \t\tif (!algo->IsPaused())\n>  \t\t\talgo->Process(stats, image_metadata);\n> -\tRPI_LOG(\"Controller::Process finished\");\n> +\tLOG(RPiController, Debug) << \"Controller::Process finished\";\n>  }\n>  \n>  Metadata &Controller::GetGlobalMetadata()","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 36F67BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 23 Jan 2021 11:15:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A42268293;\n\tSat, 23 Jan 2021 12:15:47 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E339681DC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Jan 2021 12:15:46 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82F14DA;\n\tSat, 23 Jan 2021 12:15:45 +0100 (CET)"],"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=\"RA5pBMtc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611400545;\n\tbh=pln+3pu/QokXla2VvR2F7iopO1cZNwAfMz2B/BE0s9c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RA5pBMtc3vMOZQps2lHyFD/G058EUzCPjgkITS5/rquN4NwylfKjl3OWuvczeeiZy\n\t2QIOxfim0VSm4qIHWblSObW3C/8n75oCXhEBKIKT6cLXz7TKjaOOcRatzb2t2/kO9H\n\tq6qW/XxH22JAqMKEyrNp8rD9JQOExPFRwB427ocU=","Date":"Sat, 23 Jan 2021 13:15:25 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YAv3PY55e41hNF07@pendragon.ideasonboard.com>","References":"<20210122102211.12768-1-david.plowman@raspberrypi.com>\n\t<20210122102211.12768-2-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210122102211.12768-2-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 1/5] ipa: raspberrypi: controller:\n\tReplace Raspberry Pi debug with libcamera debug","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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}}]