[{"id":23563,"web_url":"https://patchwork.libcamera.org/comment/23563/","msgid":"<165605851181.1149771.4387659843419348361@Monstersaurus>","date":"2022-06-24T08:15:11","subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Tomi Valkeinen (2022-06-23 15:47:31)\n> Add Python logging category, and use it in handleRequestCompleted().\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> ---\n>  src/py/libcamera/py_main.cpp |  8 ++++++--\n>  src/py/libcamera/py_main.h   | 12 ++++++++++++\n>  2 files changed, 18 insertions(+), 2 deletions(-)\n>  create mode 100644 src/py/libcamera/py_main.h\n> \n> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> index 505cc3dc..17b17f60 100644\n> --- a/src/py/libcamera/py_main.cpp\n> +++ b/src/py/libcamera/py_main.cpp\n> @@ -5,6 +5,8 @@\n>   * Python bindings\n>   */\n>  \n> +#include \"py_main.h\"\n> +\n>  #include <mutex>\n>  #include <stdexcept>\n>  #include <sys/eventfd.h>\n> @@ -23,6 +25,8 @@ namespace py = pybind11;\n>  \n>  using namespace libcamera;\n>  \n> +LOG_DEFINE_CATEGORY(Python)\n> +\n>  template<typename T>\n>  static py::object valueOrTuple(const ControlValue &cv)\n>  {\n> @@ -120,10 +124,10 @@ static void handleRequestCompleted(Request *req)\n>         size_t s = write(gEventfd, &v, 8);\n>         /*\n>          * We should never fail, and have no simple means to manage the error,\n> -        * so let's use LOG(Fatal).\n> +        * so let's use LOG(Python, Fatal).\n>          */\n>         if (s != 8)\n> -               LOG(Fatal) << \"Unable to write to eventfd\";\n> +               LOG(Python, Fatal) << \"Unable to write to eventfd\";\n>  }\n>  \n>  void init_py_enums(py::module &m);\n> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\n> new file mode 100644\n> index 00000000..1b543a55\n> --- /dev/null\n> +++ b/src/py/libcamera/py_main.h\n> @@ -0,0 +1,12 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> + */\n> +\n> +#pragma once\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +using namespace libcamera;\n> +\n> +LOG_DECLARE_CATEGORY(Python)\n> -- \n> 2.34.1\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 83637BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jun 2022 08:15:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4270B65635;\n\tFri, 24 Jun 2022 10:15:15 +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 2A6F965631\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jun 2022 10:15:14 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0769DD;\n\tFri, 24 Jun 2022 10:15:13 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656058515;\n\tbh=5+QRtLwLHN4kW2hFBeN/T8u6ZrHVSoSsMMT/WHEfezs=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=TLz1pnaigAnce19EPEnfHh3GCULr8oPpqweBYlt1rZZQ/RITy+9ekLRWAF46P8l+x\n\t6MrzW5yUDv64aIex2Zh+3M1AVmcy3FW1oSJS9+u57RafzazCLqPPTgK/oclzYDCAe0\n\tyfR5eTyz8pP6MqDhflIpCPG4fkacFhAazTEmcrGQdliHMmosQmcqx4/UB/eE+ZxQ+6\n\tf4fG7duiV+OtqqxspcEmieVUa0e0y8CW4J6WQIgecBgT+vAqFJH7ld4q4Rijn+l9Qw\n\tRjjIs0UXpVW9kiMkuKYS8g1jhrYN0u8TNU2ETcwJm//144GaFvUKBDzyzmNQhx8q7m\n\tPfAhh1d2graog==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656058513;\n\tbh=5+QRtLwLHN4kW2hFBeN/T8u6ZrHVSoSsMMT/WHEfezs=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=vDRDC7JYazCyyD8SX/qJE2PmSFzxCQsuzZgTP9ej69zguOR0B7KVhumwDCXr9Bf4m\n\t0PL9yVPxUIfMg6yIHS74sqREmu5rm+C8VUS8KKLKqN9pbmFH8h6beFd3+fCTKrbKt6\n\t+imiXgLMvqRbBFzVnpOoZmYOB8RCsJHjrE4YA5WY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vDRDC7JY\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>","References":"<20220623144736.78537-1-tomi.valkeinen@ideasonboard.com>\n\t<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tJacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 24 Jun 2022 09:15:11 +0100","Message-ID":"<165605851181.1149771.4387659843419348361@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23566,"web_url":"https://patchwork.libcamera.org/comment/23566/","msgid":"<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>","date":"2022-06-24T09:50:51","subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nThank you for the patch.\n\nOn Thu, Jun 23, 2022 at 05:47:31PM +0300, Tomi Valkeinen wrote:\n> Add Python logging category, and use it in handleRequestCompleted().\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> ---\n>  src/py/libcamera/py_main.cpp |  8 ++++++--\n>  src/py/libcamera/py_main.h   | 12 ++++++++++++\n>  2 files changed, 18 insertions(+), 2 deletions(-)\n>  create mode 100644 src/py/libcamera/py_main.h\n> \n> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> index 505cc3dc..17b17f60 100644\n> --- a/src/py/libcamera/py_main.cpp\n> +++ b/src/py/libcamera/py_main.cpp\n> @@ -5,6 +5,8 @@\n>   * Python bindings\n>   */\n>  \n> +#include \"py_main.h\"\n> +\n>  #include <mutex>\n>  #include <stdexcept>\n>  #include <sys/eventfd.h>\n> @@ -23,6 +25,8 @@ namespace py = pybind11;\n>  \n>  using namespace libcamera;\n>  \n> +LOG_DEFINE_CATEGORY(Python)\n> +\n>  template<typename T>\n>  static py::object valueOrTuple(const ControlValue &cv)\n>  {\n> @@ -120,10 +124,10 @@ static void handleRequestCompleted(Request *req)\n>  \tsize_t s = write(gEventfd, &v, 8);\n>  \t/*\n>  \t * We should never fail, and have no simple means to manage the error,\n> -\t * so let's use LOG(Fatal).\n> +\t * so let's use LOG(Python, Fatal).\n\nYou could also write \"so let's log a fatal error\".\n\n>  \t */\n>  \tif (s != 8)\n> -\t\tLOG(Fatal) << \"Unable to write to eventfd\";\n> +\t\tLOG(Python, Fatal) << \"Unable to write to eventfd\";\n>  }\n>  \n>  void init_py_enums(py::module &m);\n> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\n> new file mode 100644\n> index 00000000..1b543a55\n> --- /dev/null\n> +++ b/src/py/libcamera/py_main.h\n> @@ -0,0 +1,12 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> + */\n> +\n> +#pragma once\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +using namespace libcamera;\n\n\"using namespace\" directives are discouraged in header files, as they\nwill propagate to all compilation units. Could this be avoided ? With\nthat fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +LOG_DECLARE_CATEGORY(Python)","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 A4FD0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jun 2022 09:51:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E229165635;\n\tFri, 24 Jun 2022 11:51:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F35265631\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jun 2022 11:51:09 +0200 (CEST)","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 643B2DD;\n\tFri, 24 Jun 2022 11:51:08 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656064269;\n\tbh=EaE4fEkMGWISbimngUI2w7XY2CZoGy6J0BOgAzKBaKQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Gq6+zP24ccc89A42MPuH5OoE+0L+iXZtJftDEd72JFSuOO8MJefDvTfHBXyfEdOUu\n\tUrw9e6vTm1bw8oai8qVMF3iuGdY71CpIBcY8UJPQH6p8MzT0+/MKWT3qI2SURB3/uC\n\t78OUWDa3SkNBrO6G1Y8JFdd50PEhM+vXOcgEw3NC1N/Ytz4idDM0sCn1TAO+q2SUlE\n\tI3YUXVCYp6LhYeUYafELNlupByJM+f9Sz5LyBf9xdM5z+6cL3B64bCjazGTFE+hMgC\n\th7iyeKolzquggx1LzRX8DYrI1XYlxIJzBz6uEU1SdgJBVZwzdOb/P+dMhIwJkWnFff\n\tTs2NP6wM/5pMQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656064268;\n\tbh=EaE4fEkMGWISbimngUI2w7XY2CZoGy6J0BOgAzKBaKQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=e0jhdHQ7t/Wzeq+9RSNTvfRP2grOCAc+p7l8BWRN5dNW9plPkdpxKoc5KhYwQWeZC\n\tgCwTAlLeR1iftBKwgcWIpZnh3bY2hge6emg8o34P0faoIu+a4ZebIRkyBIc1FIvBu+\n\tLV6i7w97iqTQpKIoWrRib7KJvf01yGRXJNATU25s="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"e0jhdHQ7\"; dkim-atps=neutral","Date":"Fri, 24 Jun 2022 12:50:51 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>","References":"<20220623144736.78537-1-tomi.valkeinen@ideasonboard.com>\n\t<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23587,"web_url":"https://patchwork.libcamera.org/comment/23587/","msgid":"<c6035072-12c6-333c-24a8-e08d83496154@ideasonboard.com>","date":"2022-06-27T06:48:34","subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"On 24/06/2022 12:50, Laurent Pinchart wrote:\n> Hi Tomi,\n> \n> Thank you for the patch.\n> \n> On Thu, Jun 23, 2022 at 05:47:31PM +0300, Tomi Valkeinen wrote:\n>> Add Python logging category, and use it in handleRequestCompleted().\n>>\n>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>> ---\n>>   src/py/libcamera/py_main.cpp |  8 ++++++--\n>>   src/py/libcamera/py_main.h   | 12 ++++++++++++\n>>   2 files changed, 18 insertions(+), 2 deletions(-)\n>>   create mode 100644 src/py/libcamera/py_main.h\n>>\n>> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n>> index 505cc3dc..17b17f60 100644\n>> --- a/src/py/libcamera/py_main.cpp\n>> +++ b/src/py/libcamera/py_main.cpp\n>> @@ -5,6 +5,8 @@\n>>    * Python bindings\n>>    */\n>>   \n>> +#include \"py_main.h\"\n>> +\n>>   #include <mutex>\n>>   #include <stdexcept>\n>>   #include <sys/eventfd.h>\n>> @@ -23,6 +25,8 @@ namespace py = pybind11;\n>>   \n>>   using namespace libcamera;\n>>   \n>> +LOG_DEFINE_CATEGORY(Python)\n>> +\n>>   template<typename T>\n>>   static py::object valueOrTuple(const ControlValue &cv)\n>>   {\n>> @@ -120,10 +124,10 @@ static void handleRequestCompleted(Request *req)\n>>   \tsize_t s = write(gEventfd, &v, 8);\n>>   \t/*\n>>   \t * We should never fail, and have no simple means to manage the error,\n>> -\t * so let's use LOG(Fatal).\n>> +\t * so let's use LOG(Python, Fatal).\n> \n> You could also write \"so let's log a fatal error\".\n\nYep.\n\n>>   \t */\n>>   \tif (s != 8)\n>> -\t\tLOG(Fatal) << \"Unable to write to eventfd\";\n>> +\t\tLOG(Python, Fatal) << \"Unable to write to eventfd\";\n>>   }\n>>   \n>>   void init_py_enums(py::module &m);\n>> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\n>> new file mode 100644\n>> index 00000000..1b543a55\n>> --- /dev/null\n>> +++ b/src/py/libcamera/py_main.h\n>> @@ -0,0 +1,12 @@\n>> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n>> +/*\n>> + * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>> + */\n>> +\n>> +#pragma once\n>> +\n>> +#include <libcamera/base/log.h>\n>> +\n>> +using namespace libcamera;\n> \n> \"using namespace\" directives are discouraged in header files, as they\n> will propagate to all compilation units. Could this be avoided ? With\n> that fixed,\n\nLOG_DECLARE_CATEGORY() requires either using namespace or being inside \nlibcamera namespace.\n\nI guess I could move all the python bindings code to be inside libcamera \nnamespace. Then again, these are bindings internal headers and as such \nthe using namespace should cause no issues.\n\n  Tomi","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 5211BBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Jun 2022 06:48:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BDA7865637;\n\tMon, 27 Jun 2022 08:48:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 05A4B6054A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Jun 2022 08:48:38 +0200 (CEST)","from [192.168.1.111] (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 389B947C;\n\tMon, 27 Jun 2022 08:48:37 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656312518;\n\tbh=i77QJtu3/6l1xVEyDlOtlGfknlfEmsODtmnaK6Y9fPs=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=PaCWPrQaL5XmoKe3b6ICTO85/9IIV9myh5CUQfD0iDtoxypmY5NZxAKJO0z+gpQiD\n\t2Ks+e42FaciMZG373S/CHvot/pNFx2ywuic/PylCyT+oTOoVT2pNnwI6CMa1wa1SIL\n\tpFXW8z+F2LMIOcl8rz/uQjnyBiGlLJlTJU91g8/uCIrbV4IMvcg+UL7SJ+cjiiH7Ay\n\twg/7tPCtIQY0YS5ptZ3M3epu7Lof4G1UmKkreVGkNoBH9DbI/I/MZm6B5V2/ZDvqXK\n\t+lDUKBUwC2CSyByBpM3gLmdTztH1L4/tPn2ACvqh4DsXNFMig5juoNB2IwhFwRgftl\n\tEKlkdElc1gHWQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656312517;\n\tbh=i77QJtu3/6l1xVEyDlOtlGfknlfEmsODtmnaK6Y9fPs=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=RR4D79yBYKN69xhv8Y6ojsKFKkOMs9DVEeXm2fDdxxkUNmWdEtUSHxZ/D16iGXmTa\n\trd2VD8n7nKDXQY9RVvHbm2s3H81IzQBkN/81Oeezi6I0TjS/+UPjcDDrPQBBBc5zeF\n\tIWiGfDdGLzJxV3oTjo9vrGjKsGTL22L409c8LizQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"RR4D79yB\"; dkim-atps=neutral","Message-ID":"<c6035072-12c6-333c-24a8-e08d83496154@ideasonboard.com>","Date":"Mon, 27 Jun 2022 09:48:34 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.9.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20220623144736.78537-1-tomi.valkeinen@ideasonboard.com>\n\t<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>\n\t<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>","In-Reply-To":"<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","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":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23591,"web_url":"https://patchwork.libcamera.org/comment/23591/","msgid":"<YrlnyvSTrc3Titdn@pendragon.ideasonboard.com>","date":"2022-06-27T08:18:18","subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nOn Mon, Jun 27, 2022 at 09:48:34AM +0300, Tomi Valkeinen wrote:\n> On 24/06/2022 12:50, Laurent Pinchart wrote:\n> > On Thu, Jun 23, 2022 at 05:47:31PM +0300, Tomi Valkeinen wrote:\n> >> Add Python logging category, and use it in handleRequestCompleted().\n> >>\n> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >> ---\n> >>   src/py/libcamera/py_main.cpp |  8 ++++++--\n> >>   src/py/libcamera/py_main.h   | 12 ++++++++++++\n> >>   2 files changed, 18 insertions(+), 2 deletions(-)\n> >>   create mode 100644 src/py/libcamera/py_main.h\n> >>\n> >> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> >> index 505cc3dc..17b17f60 100644\n> >> --- a/src/py/libcamera/py_main.cpp\n> >> +++ b/src/py/libcamera/py_main.cpp\n> >> @@ -5,6 +5,8 @@\n> >>    * Python bindings\n> >>    */\n> >>   \n> >> +#include \"py_main.h\"\n> >> +\n> >>   #include <mutex>\n> >>   #include <stdexcept>\n> >>   #include <sys/eventfd.h>\n> >> @@ -23,6 +25,8 @@ namespace py = pybind11;\n> >>   \n> >>   using namespace libcamera;\n> >>   \n> >> +LOG_DEFINE_CATEGORY(Python)\n> >> +\n> >>   template<typename T>\n> >>   static py::object valueOrTuple(const ControlValue &cv)\n> >>   {\n> >> @@ -120,10 +124,10 @@ static void handleRequestCompleted(Request *req)\n> >>   \tsize_t s = write(gEventfd, &v, 8);\n> >>   \t/*\n> >>   \t * We should never fail, and have no simple means to manage the error,\n> >> -\t * so let's use LOG(Fatal).\n> >> +\t * so let's use LOG(Python, Fatal).\n> > \n> > You could also write \"so let's log a fatal error\".\n> \n> Yep.\n> \n> >>   \t */\n> >>   \tif (s != 8)\n> >> -\t\tLOG(Fatal) << \"Unable to write to eventfd\";\n> >> +\t\tLOG(Python, Fatal) << \"Unable to write to eventfd\";\n> >>   }\n> >>   \n> >>   void init_py_enums(py::module &m);\n> >> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\n> >> new file mode 100644\n> >> index 00000000..1b543a55\n> >> --- /dev/null\n> >> +++ b/src/py/libcamera/py_main.h\n> >> @@ -0,0 +1,12 @@\n> >> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> >> +/*\n> >> + * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >> + */\n> >> +\n> >> +#pragma once\n> >> +\n> >> +#include <libcamera/base/log.h>\n> >> +\n> >> +using namespace libcamera;\n> > \n> > \"using namespace\" directives are discouraged in header files, as they\n> > will propagate to all compilation units. Could this be avoided ? With\n> > that fixed,\n> \n> LOG_DECLARE_CATEGORY() requires either using namespace or being inside \n> libcamera namespace.\n> \n> I guess I could move all the python bindings code to be inside libcamera \n> namespace.\n\nYou can also do\n\nnamespace libcamera {\n\nLOG_DECLARE_CATEGORY(Python)\n\n}\n\n> Then again, these are bindings internal headers and as such \n> the using namespace should cause no issues.\n\nThat's true, but it's still not a great practice, and if it's easy to\nfix, it could prevent problems later (and it's also nice not to give any\nexcuse for cargo-cult misuse of \"using namespace\" directives :-)).","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 E8F08BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Jun 2022 08:18:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A48965635;\n\tMon, 27 Jun 2022 10:18:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1126760412\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Jun 2022 10:18:37 +0200 (CEST)","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 4727447C;\n\tMon, 27 Jun 2022 10:18:36 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656317918;\n\tbh=aaf8r+EN2322BIVmZdcQc7eYaU22Dv1tVzux5J8jIqU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=F/DdYqHSbe1vLm5p4GAVrcypW/wqj8qeT8lAhH+IFrEYRH3Eigu8ShrRv1qT8Kb8u\n\tUW81zVjGN7yJThmywPWnHT73nKXtSHBdN/Nxeha6xhjiOxz0lpkDWONkdsA9IvPmLi\n\twArzG5JEcXRF6xvDohItdGHEbJa6bFBxSOfg2dmtrBmivy8hO5KlWDX7N2zgc8sgbf\n\t8i2phOASfDHtN5JVJCBV55gMv7JztQS4dmvo+C/6k6KYqed5NSz19zhTb10+phsuyM\n\td6LVMUnb/6oDDqnEl4baP/Swpfr/yKZ3c6z0eQtIXy2WKbWLfMKVX1RlBMtJPsIayv\n\t0coU5GU/EW9dg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656317916;\n\tbh=aaf8r+EN2322BIVmZdcQc7eYaU22Dv1tVzux5J8jIqU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=E80XLIxkKA6NPcQ2C6urpMGE+y3fEIr8pI1XLvPV1RCvfNlWtz8S71pE07/DO9gSN\n\tY9vCjEp+iBLHLFZeVMh3yaig0qnjGmcEAmzxqL5UaLpM2rcgUPin03hmUOSy4GFqUg\n\tJGJh2SOB7uyYb2FqhLYxRCfWIq0CF/a/ljzRUDyU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"E80XLIxk\"; dkim-atps=neutral","Date":"Mon, 27 Jun 2022 11:18:18 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<YrlnyvSTrc3Titdn@pendragon.ideasonboard.com>","References":"<20220623144736.78537-1-tomi.valkeinen@ideasonboard.com>\n\t<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>\n\t<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>\n\t<c6035072-12c6-333c-24a8-e08d83496154@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<c6035072-12c6-333c-24a8-e08d83496154@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23606,"web_url":"https://patchwork.libcamera.org/comment/23606/","msgid":"<6f8ba72c-7d6f-fccc-6031-1d201feb86f3@ideasonboard.com>","date":"2022-06-27T12:14:23","subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"On 27/06/2022 11:18, Laurent Pinchart wrote:\n> Hi Tomi,\n> \n> On Mon, Jun 27, 2022 at 09:48:34AM +0300, Tomi Valkeinen wrote:\n>> On 24/06/2022 12:50, Laurent Pinchart wrote:\n>>> On Thu, Jun 23, 2022 at 05:47:31PM +0300, Tomi Valkeinen wrote:\n>>>> Add Python logging category, and use it in handleRequestCompleted().\n>>>>\n>>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>>>> ---\n>>>>    src/py/libcamera/py_main.cpp |  8 ++++++--\n>>>>    src/py/libcamera/py_main.h   | 12 ++++++++++++\n>>>>    2 files changed, 18 insertions(+), 2 deletions(-)\n>>>>    create mode 100644 src/py/libcamera/py_main.h\n>>>>\n>>>> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n>>>> index 505cc3dc..17b17f60 100644\n>>>> --- a/src/py/libcamera/py_main.cpp\n>>>> +++ b/src/py/libcamera/py_main.cpp\n>>>> @@ -5,6 +5,8 @@\n>>>>     * Python bindings\n>>>>     */\n>>>>    \n>>>> +#include \"py_main.h\"\n>>>> +\n>>>>    #include <mutex>\n>>>>    #include <stdexcept>\n>>>>    #include <sys/eventfd.h>\n>>>> @@ -23,6 +25,8 @@ namespace py = pybind11;\n>>>>    \n>>>>    using namespace libcamera;\n>>>>    \n>>>> +LOG_DEFINE_CATEGORY(Python)\n>>>> +\n>>>>    template<typename T>\n>>>>    static py::object valueOrTuple(const ControlValue &cv)\n>>>>    {\n>>>> @@ -120,10 +124,10 @@ static void handleRequestCompleted(Request *req)\n>>>>    \tsize_t s = write(gEventfd, &v, 8);\n>>>>    \t/*\n>>>>    \t * We should never fail, and have no simple means to manage the error,\n>>>> -\t * so let's use LOG(Fatal).\n>>>> +\t * so let's use LOG(Python, Fatal).\n>>>\n>>> You could also write \"so let's log a fatal error\".\n>>\n>> Yep.\n>>\n>>>>    \t */\n>>>>    \tif (s != 8)\n>>>> -\t\tLOG(Fatal) << \"Unable to write to eventfd\";\n>>>> +\t\tLOG(Python, Fatal) << \"Unable to write to eventfd\";\n>>>>    }\n>>>>    \n>>>>    void init_py_enums(py::module &m);\n>>>> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\n>>>> new file mode 100644\n>>>> index 00000000..1b543a55\n>>>> --- /dev/null\n>>>> +++ b/src/py/libcamera/py_main.h\n>>>> @@ -0,0 +1,12 @@\n>>>> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n>>>> +/*\n>>>> + * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>>>> + */\n>>>> +\n>>>> +#pragma once\n>>>> +\n>>>> +#include <libcamera/base/log.h>\n>>>> +\n>>>> +using namespace libcamera;\n>>>\n>>> \"using namespace\" directives are discouraged in header files, as they\n>>> will propagate to all compilation units. Could this be avoided ? With\n>>> that fixed,\n>>\n>> LOG_DECLARE_CATEGORY() requires either using namespace or being inside\n>> libcamera namespace.\n>>\n>> I guess I could move all the python bindings code to be inside libcamera\n>> namespace.\n> \n> You can also do\n> \n> namespace libcamera {\n> \n> LOG_DECLARE_CATEGORY(Python)\n> \n> }\n\nThat's true. I'll change this as above, and maybe later move the whole \nbindings inside namespace libcamera. Or any concerns with that change?\n\n  Tomi","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 24C0ABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Jun 2022 12:14:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8637465635;\n\tMon, 27 Jun 2022 14:14:28 +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 145BB6059B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Jun 2022 14:14:27 +0200 (CEST)","from [192.168.1.111] (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C8A91C82;\n\tMon, 27 Jun 2022 14:14:26 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656332068;\n\tbh=W6CsbF2+E+fcpA6HGk9p6CwZ+e/ROZGtQfi/TYUvxBA=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=x3t1Gc+yNbHX/5y6L/cM1WnQ0wMCPlukctGt5EP21z33UlWRoF9ZPiiL3hpK7hBhp\n\tPEBqyuUdNqNhxXujwjebVZY9/xho/UtrirejTgqHVHdDtE4xEX2EzZlA4UPzOumVT8\n\tD+ENhrJ81OnXRGex28UJG0y7IuGN1Ksqi3DfxWxKpfQwviu+n/dp3GYBRubs1hdTb1\n\tmj2sy6DOlU01kLmXThXEfACytxIzaKFIbPiMjmzApnQUtDAVym17yE76MvfWVfnwbE\n\tXk0+EAQQssnHeruDQ9ePPsOihvAXp2Jh42dmQwE4r02KWcHZ9UjjEQ3aQ76Q2llIW5\n\tXzKvdpiEYOENw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656332066;\n\tbh=W6CsbF2+E+fcpA6HGk9p6CwZ+e/ROZGtQfi/TYUvxBA=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=I8L07V/jD6zXtCSUiaWFMLV4nWJGnzlJwWJX4x8OzuoVdGft/M3fDF0RxTIu8TWU8\n\t8lJWfQbyqvJnsYdTxvvHBT2PeSdhitGUbsfk4oFLdWetDA+Rcn5nKlMLn8Kk0LSlwC\n\tk5xml/+EW96ASMgR2dS4xz92UM0UHMbjm29Rw6x8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"I8L07V/j\"; dkim-atps=neutral","Message-ID":"<6f8ba72c-7d6f-fccc-6031-1d201feb86f3@ideasonboard.com>","Date":"Mon, 27 Jun 2022 15:14:23 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.9.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20220623144736.78537-1-tomi.valkeinen@ideasonboard.com>\n\t<20220623144736.78537-3-tomi.valkeinen@ideasonboard.com>\n\t<YrWI+3QQKaVKO+BV@pendragon.ideasonboard.com>\n\t<c6035072-12c6-333c-24a8-e08d83496154@ideasonboard.com>\n\t<YrlnyvSTrc3Titdn@pendragon.ideasonboard.com>","In-Reply-To":"<YrlnyvSTrc3Titdn@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [RFC v1 2/7] py: Add Python logging category","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":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]