[{"id":776,"web_url":"https://patchwork.libcamera.org/comment/776/","msgid":"<20190210131504.GB31044@bigcity.dyn.berto.se>","date":"2019-02-10T13:15:04","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: v4l2_device: Inherit\n\tfrom Loggable to print device node name","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2019-02-08 16:45:40 +0200, Laurent Pinchart wrote:\n> Automate printing of device node name in log messages by inheriting from\n> the Loggable class.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_device.h |  7 ++++++-\n>  src/libcamera/v4l2_device.cpp       | 16 +++++++++-------\n>  2 files changed, 15 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 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);\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B9D2C610B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 10 Feb 2019 14:15:05 +0100 (CET)","by mail-lj1-x243.google.com with SMTP id s5-v6so6569311ljd.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 10 Feb 2019 05:15:05 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tx11sm1765802lfd.81.2019.02.10.05.15.04\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Feb 2019 05:15:04 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=ipg8szKKvmKt1DUkwYJi0aZ5nhEPTRj7JRWt2oSGiBw=;\n\tb=IoM4qEkXhC+0gpnQ4TyZ1F7w2gPetqDkEGlteM1woC789PK3vS7qZBPQi9Rjcj1y/M\n\tsVq+5wbHGwOhhOqofHFNTzJph8EdHAn6q1Fs9ojXdizvdJO/131zu7CEriZXVK6RVkQn\n\tLI7+yfonIXrolL+FnzW6xKX/vRtdwV5vgUAgUsOb7OSdzN1ITO2L7q6TUjsxxMQMVH0C\n\tULbgvVXP0y/uBhhWYI9kUVFy/oVieT9Nxyw4Z9ChzRSNjw1FWcray5JaAsBZsQM8H+xY\n\tHsiEzvIXn3TJE9PzP5ndUW98IQ1vyf4AN/SvaB9T2f49IIg4yqSBz6ZhfrRVOqNOdNbp\n\tD/zA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=ipg8szKKvmKt1DUkwYJi0aZ5nhEPTRj7JRWt2oSGiBw=;\n\tb=PRQFB6z1wa3JCzyTEXhIu9Mm1S+gok8A2X3VifB+Khb2RotzwrZW3Xa3ktZhlGUFKe\n\tKvacxJLxWrBbcrNXa8dMOrSqRVkjJkgesJIwRWTMaz/mDakuTfM13mSLVmMh9zc9uy5q\n\toCjgs+DPnEHMV7HT/x7zz7yatIKj6PSA5OyC+6pj8H9qBUEb0blF2YSmAowpvpldNBr0\n\tRna1Wkg72btPYty5QNAw53D2xH0G3mNl0S442/jQDHNWm//9NOyx7a2Ursv2mNqQASrg\n\tiqyajcfNDu78gg+EpaEmWobHBa3lwZvHrV34HdyZAh+1i0kaBOgRFHvx+vl87hdJLUwk\n\tiz6A==","X-Gm-Message-State":"AHQUAub+PA3Yz4AognoS8bd44iEBrDHk9Hldcy+neUBAzU3kL9I61u9P\n\t1rjL31UQZI+qKrq+eX2zZ/904/3yuCo=","X-Google-Smtp-Source":"AHgI3IbO72apFGm35k9Jp1R6DZiMpEDLbJhvqV33MEJUCmOZ43cb9L8Yj0xogzrxmSDY215j0O6gHQ==","X-Received":"by 2002:a2e:a0c8:: with SMTP id\n\tf8-v6mr4607792ljm.177.1549804505037; \n\tSun, 10 Feb 2019 05:15:05 -0800 (PST)","Date":"Sun, 10 Feb 2019 14:15:04 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190210131504.GB31044@bigcity.dyn.berto.se>","References":"<20190208144540.15529-1-laurent.pinchart@ideasonboard.com>\n\t<20190208144540.15529-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190208144540.15529-2-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: v4l2_device: Inherit\n\tfrom Loggable 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":"Sun, 10 Feb 2019 13:15:06 -0000"}}]