{"id":551,"url":"https://patchwork.libcamera.org/api/1.1/patches/551/?format=json","web_url":"https://patchwork.libcamera.org/patch/551/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190208144540.15529-2-laurent.pinchart@ideasonboard.com>","date":"2019-02-08T14:45:40","name":"[libcamera-devel,2/2] libcamera: v4l2_device: Inherit from Loggable to print device node name","commit_ref":"04d5be7f76fe350997d7cd1c1ea54a5b1972404e","pull_url":null,"state":"accepted","archived":false,"hash":"cf0a23a004ecaa51d809588b4d7aae4804ad10dd","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/551/mbox/","series":[{"id":173,"url":"https://patchwork.libcamera.org/api/1.1/series/173/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=173","date":"2019-02-08T14:45:39","name":"[libcamera-devel,1/2] libcamera: log: Allow extending log messages","version":1,"mbox":"https://patchwork.libcamera.org/series/173/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/551/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/551/checks/","tags":{},"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 823016101F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Feb 2019 15:45:45 +0100 (CET)","from pendragon.ideasonboard.com (d51A4137F.access.telenet.be\n\t[81.164.19.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F23572E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Feb 2019 15:45:44 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549637145;\n\tbh=kkYP1rswu/B3HjKfSzc+NMur8lmJWJrBBeSgpRs76AA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=tcxMIRD+jevS+s0f8AWJBFFklKhwEcQdv4Ixw7xs3qVAtZ0B6z6SS3mzgILP9Jkv9\n\t9ulqj/+DltpkawofhaBKHyct+y12kGEc0QSDEuMyuzLZYqXKSQXmzIiUjVMlWSTwaY\n\tc1Bzl2PKuPWMte32pVFh5fCXu0pVnwjCsS4pU7t4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  8 Feb 2019 16:45:40 +0200","Message-Id":"<20190208144540.15529-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190208144540.15529-1-laurent.pinchart@ideasonboard.com>","References":"<20190208144540.15529-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/2] libcamera: v4l2_device: Inherit from\n\tLoggable to print device node name","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":"Fri, 08 Feb 2019 14:45:45 -0000"},"content":"Automate printing of device node name in log messages by inheriting from\nthe Loggable class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  7 ++++++-\n src/libcamera/v4l2_device.cpp       | 16 +++++++++-------\n 2 files changed, 15 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 988e646c5de1..983b9d900aea 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -15,6 +15,8 @@\n \n #include <libcamera/signal.h>\n \n+#include \"log.h\"\n+\n namespace libcamera {\n \n class Buffer;\n@@ -76,7 +78,7 @@ public:\n \tunsigned int planesCount;\n };\n \n-class V4L2Device\n+class V4L2Device : protected Loggable\n {\n public:\n \texplicit V4L2Device(const std::string &deviceNode);\n@@ -106,6 +108,9 @@ public:\n \tint streamOn();\n \tint streamOff();\n \n+protected:\n+\tstd::string logPrefix() const;\n+\n private:\n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n \tint setFormatSingleplane(V4L2DeviceFormat *format);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 64325ff9f5d9..23c0da295905 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -262,8 +262,7 @@ int V4L2Device::open()\n \tif (ret < 0) {\n \t\tret = -errno;\n \t\tLOG(V4L2, Error)\n-\t\t\t<< \"Failed to open V4L2 device '\" << deviceNode_\n-\t\t\t<< \"': \" << strerror(-ret);\n+\t\t\t<< \"Failed to open V4L2 device: \" << strerror(-ret);\n \t\treturn ret;\n \t}\n \tfd_ = ret;\n@@ -278,9 +277,8 @@ int V4L2Device::open()\n \t}\n \n \tLOG(V4L2, Debug)\n-\t\t<< \"Opened '\" << deviceNode_ << \"' \"\n-\t\t<< caps_.bus_info() << \": \" << caps_.driver()\n-\t\t<< \": \" << caps_.card();\n+\t\t<< \"Opened device \" << caps_.bus_info() << \": \"\n+\t\t<< caps_.driver() << \": \" << caps_.card();\n \n \tif (!caps_.isCapture() && !caps_.isOutput()) {\n \t\tLOG(V4L2, Debug) << \"Device is not a supported type\";\n@@ -350,6 +348,11 @@ void V4L2Device::close()\n  * \\return The string containing the device location\n  */\n \n+std::string V4L2Device::logPrefix() const\n+{\n+\treturn deviceNode_;\n+}\n+\n /**\n  * \\brief Retrieve the image format set on the V4L2 device\n  * \\param[out] format The image format applied on the device\n@@ -519,8 +522,7 @@ int V4L2Device::requestBuffers(unsigned int count)\n \t\treturn ret;\n \t}\n \n-\tLOG(V4L2, Debug)\n-\t\t<< deviceNode_ << \":\" << rb.count << \" buffers requested.\";\n+\tLOG(V4L2, Debug) << rb.count << \" buffers requested.\";\n \n \treturn rb.count;\n }\n","prefixes":["libcamera-devel","2/2"]}