From patchwork Wed Feb 27 17:38:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 641 Return-Path: Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1880A610B6 for ; Wed, 27 Feb 2019 18:38:15 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 6683A100009; Wed, 27 Feb 2019 17:38:14 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Feb 2019 18:38:31 +0100 Message-Id: <20190227173837.6902-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190227173837.6902-1-jacopo@jmondi.org> References: <20190227173837.6902-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/8] libcamera: v4l2_subdevice: Inherit from Loggable X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2019 17:38:15 -0000 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 Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_subdevice.h | 6 +++++- src/libcamera/v4l2_subdevice.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h index eac699a06109..dc311034a8ee 100644 --- a/src/libcamera/include/v4l2_subdevice.h +++ b/src/libcamera/include/v4l2_subdevice.h @@ -9,6 +9,7 @@ #include +#include "log.h" #include "media_object.h" namespace libcamera { @@ -21,7 +22,7 @@ struct V4L2SubdeviceFormat { uint32_t height; }; -class V4L2Subdevice +class V4L2Subdevice : protected Loggable { public: explicit V4L2Subdevice(const MediaEntity *entity); @@ -41,6 +42,9 @@ public: int getFormat(unsigned int pad, V4L2SubdeviceFormat *format); int setFormat(unsigned int pad, V4L2SubdeviceFormat *format); +protected: + std::string logPrefix() const { return "'" + deviceName() + "'"; } + private: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index c44cafd4b4c5..dbb54506ee41 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -196,7 +196,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 +231,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 +263,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; }