[{"id":907,"web_url":"https://patchwork.libcamera.org/comment/907/","msgid":"<e7d750ed-e3d2-a5f4-2b47-9634a780dae2@ideasonboard.com>","date":"2019-02-27T00:00:35","subject":"Re: [libcamera-devel] [PATCH v3 8/8] libcamera: v4l2_subdevice:\n\tInherit from Loggable","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 26/02/2019 16:26, Jacopo Mondi wrote:\n> Prefix the V4L2Subdevice error messages with the name of the entity.\n> Remove the manually printed name from log messages where it was used.\nThis will certainly make it easier to keep log lines tied to a specific\ninstance.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |  7 ++++++-\n>  src/libcamera/v4l2_subdevice.cpp       | 10 ++++------\n>  2 files changed, 10 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 6b21308d2087..dcf38d719fcb 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -13,6 +13,8 @@\n>  \n>  #include \"media_object.h\"\n>  \n> +#include \"log.h\"\n> +\n>  namespace libcamera {\n>  \n>  struct Rectangle;\n> @@ -23,7 +25,7 @@ struct V4L2SubdeviceFormat {\n>  \tuint32_t height;\n>  };\n>  \n> -class V4L2Subdevice\n> +class V4L2Subdevice : protected Loggable\n>  {\n>  public:\n>  \texplicit V4L2Subdevice(const MediaEntity *entity);\n> @@ -44,6 +46,9 @@ public:\n>  \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n>  \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n>  \n> +protected:\n> +\tstd::string logPrefix() const { return \"'\" + deviceName() + \"'\"; }\n\nThe quotes feel a bit extraneous here?\n\n> +\n>  private:\n>  \tint listPadSizes(unsigned int pad, unsigned int mbus_code,\n>  \t\t\t std::vector<V4L2SubdeviceFormat> *formats);\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index a043a07ff156..20439b895b99 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -222,7 +222,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to get format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \" << strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn ret;\n>  \t}\n>  \n> @@ -311,8 +311,7 @@ int V4L2Subdevice::listPadSizes(unsigned int pad, unsigned int mbus_code,\n>  \tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to enumerate format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \"\n> -\t\t\t<< strerror(errno);\n> +\t\t\t<< \": \" << strerror(errno);\n>  \t\treturn ret;\n>  \t}\n>  \n> @@ -340,7 +339,7 @@ std::vector<V4L2SubdeviceFormat> V4L2Subdevice::listPadFormats(unsigned int pad)\n>  \tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to enumerate format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \" << strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn formats;\n>  \t}\n>  \n> @@ -380,8 +379,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> -\t\t\t<< pad << \" of \" << deviceName() << \": \"\n> -\t\t\t<< strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn ret;\n>  \t}\n>  \n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["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 3279C610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 01:00:39 +0100 (CET)","from [192.168.0.21]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 789FB67;\n\tWed, 27 Feb 2019 01:00:38 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551225638;\n\tbh=N+rxvYHZ1R6mF1XaFpVJkHUTflnMlARL3OLbl4zHIP4=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=Vfi1sspgTgb9ugzaYf9VW8muLpAilgthUttghlCJx78CCTnlEHkehboyYuZ/G/Q1f\n\tknMfaIrmQrf1P36+1/0OwJJ/8GOYoPpg93xZD23YPkkda/gETrHvMIZxsV1t7iLpCu\n\tdX0AxOLB38xO1ONFu+7X778id8HQlfERRrxFqYQ8=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-9-jacopo@jmondi.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDr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4yyY4dX9lC2JL/LOEpw8DGf5BNOP1KgjCvyp1/KcFxDAo89IeqljaRsCdP\n\t7WCIECWYem6pLwaw6IAL7oX+tEqIMPph/G/jwZcdS6Hkyt/esHPuHNwX4guqTbVEuRqbDzDI\n\t2DJO5FbxABEBAAGJAiUEGAEKAA8CGwwFAlnDlGsFCQeA/gIACgkQoR5GchCkYf1yYRAAq+Yo\n\tnbf9DGdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<e7d750ed-e3d2-a5f4-2b47-9634a780dae2@ideasonboard.com>","Date":"Wed, 27 Feb 2019 00:00:35 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.4.0","MIME-Version":"1.0","In-Reply-To":"<20190226162641.12116-9-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 8/8] libcamera: v4l2_subdevice:\n\tInherit from Loggable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Wed, 27 Feb 2019 00:00:39 -0000"}},{"id":932,"web_url":"https://patchwork.libcamera.org/comment/932/","msgid":"<20190227180706.GO4813@pendragon.ideasonboard.com>","date":"2019-02-27T18:07:06","subject":"Re: [libcamera-devel] [PATCH v3 8/8] libcamera: v4l2_subdevice:\n\tInherit from Loggable","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Feb 26, 2019 at 05:26:41PM +0100, Jacopo Mondi wrote:\n> Prefix the V4L2Subdevice error messages with the name of the entity.\n> Remove the manually printed name from log messages where it was used.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |  7 ++++++-\n>  src/libcamera/v4l2_subdevice.cpp       | 10 ++++------\n>  2 files changed, 10 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 6b21308d2087..dcf38d719fcb 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -13,6 +13,8 @@\n>  \n>  #include \"media_object.h\"\n>  \n> +#include \"log.h\"\n> +\n\nThis should go above the media_object.h include without any blank line\nin between.\n\n>  namespace libcamera {\n>  \n>  struct Rectangle;\n> @@ -23,7 +25,7 @@ struct V4L2SubdeviceFormat {\n>  \tuint32_t height;\n>  };\n>  \n> -class V4L2Subdevice\n> +class V4L2Subdevice : protected Loggable\n>  {\n>  public:\n>  \texplicit V4L2Subdevice(const MediaEntity *entity);\n> @@ -44,6 +46,9 @@ public:\n>  \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n>  \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n>  \n> +protected:\n> +\tstd::string logPrefix() const { return \"'\" + deviceName() + \"'\"; }\n\nThis will end up inlining two + operations between strings for every\ncall. Let's not make it an inline function.\n\nApart from that,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n>  private:\n>  \tint listPadSizes(unsigned int pad, unsigned int mbus_code,\n>  \t\t\t std::vector<V4L2SubdeviceFormat> *formats);\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index a043a07ff156..20439b895b99 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -222,7 +222,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to get format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \" << strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn ret;\n>  \t}\n>  \n> @@ -311,8 +311,7 @@ int V4L2Subdevice::listPadSizes(unsigned int pad, unsigned int mbus_code,\n>  \tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to enumerate format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \"\n> -\t\t\t<< strerror(errno);\n> +\t\t\t<< \": \" << strerror(errno);\n>  \t\treturn ret;\n>  \t}\n>  \n> @@ -340,7 +339,7 @@ std::vector<V4L2SubdeviceFormat> V4L2Subdevice::listPadFormats(unsigned int pad)\n>  \tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to enumerate format on pad \" << pad\n> -\t\t\t<< \" of \" << deviceName() << \": \" << strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn formats;\n>  \t}\n>  \n> @@ -380,8 +379,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> -\t\t\t<< pad << \" of \" << deviceName() << \": \"\n> -\t\t\t<< strerror(-ret);\n> +\t\t\t<< \": \" << strerror(-ret);\n>  \t\treturn ret;\n>  \t}\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF735610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 19:07:23 +0100 (CET)","from pendragon.ideasonboard.com (unknown [83.145.195.18])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E39EA49;\n\tWed, 27 Feb 2019 19:07:21 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551290843;\n\tbh=xBQ31iaecDVWLgXfY8Z6VrR4OOKgpQIl7MpFk+tp8ls=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FUsDejkPa4jUtUWZawHbPMCFWkiG1tnJpSQia6RhKyppVEnTFCDnC73xZ1eaIgKY7\n\tBJxV3ij8n2tYIFTxpeRadIYJHY8sRc/1dmXCtTi1hoxj9CGVk85kEZKBwQ4Q75tIvw\n\t2aFDHdF37kcNQcJ6vzprPFbvaZBDEqh6OZORvSyE=","Date":"Wed, 27 Feb 2019 20:07:06 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190227180706.GO4813@pendragon.ideasonboard.com>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-9-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190226162641.12116-9-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 8/8] libcamera: v4l2_subdevice:\n\tInherit from Loggable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Wed, 27 Feb 2019 18:07:24 -0000"}}]