From 204d5c9f09e8513717e968a1ab31c2f0d4b8efb3 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 26 Feb 2019 17:19:59 +0100 Subject: libcamera: v4l2_subdevice: Inherit from Loggable Prefix the V4L2Subdevice error messages with the name of the entity. Remove the manually printed name from log messages where it was used and standardize error messages while at there. Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/v4l2_subdevice.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libcamera/v4l2_subdevice.cpp') diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 143f281a..d7b61ba0 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -154,6 +154,11 @@ void V4L2Subdevice::close() * \return The name of the media entity the subdevice is associated to */ +std::string V4L2Subdevice::logPrefix() const +{ + return "'" + deviceName() + "'"; +} + /** * \brief Set a crop rectangle on one of the V4L2 subdevice pads * \param[in] pad The 0-indexed pad number the rectangle is to be applied to @@ -196,7 +201,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format) ret = -errno; LOG(V4L2Subdev, Error) << "Unable to get format on pad " << pad - << " of " << deviceNode() << ": " << strerror(-ret); + << ": " << strerror(-ret); return ret; } @@ -231,7 +236,8 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format) if (ret) { ret = -errno; LOG(V4L2Subdev, Error) - << "Unable to set format: " << strerror(-ret); + << "Unable to set format on pad " << pad + << ": " << strerror(-ret); return ret; } @@ -262,8 +268,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, ret = -errno; LOG(V4L2Subdev, Error) << "Unable to set rectangle " << target << " on pad " - << pad << " of " << deviceNode() << ": " - << strerror(-ret); + << pad << ": " << strerror(-ret); return ret; } -- cgit v1.2.1