From patchwork Tue Feb 26 16:26:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 638 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A09D610CD for ; Tue, 26 Feb 2019 17:26:23 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id AEDDD60002; Tue, 26 Feb 2019 16:26:22 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Feb 2019 17:26:41 +0100 Message-Id: <20190226162641.12116-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226162641.12116-1-jacopo@jmondi.org> References: <20190226162641.12116-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 8/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: Tue, 26 Feb 2019 16:26:23 -0000 Prefix the V4L2Subdevice error messages with the name of the entity. Remove the manually printed name from log messages where it was used. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/include/v4l2_subdevice.h | 7 ++++++- src/libcamera/v4l2_subdevice.cpp | 10 ++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h index 6b21308d2087..dcf38d719fcb 100644 --- a/src/libcamera/include/v4l2_subdevice.h +++ b/src/libcamera/include/v4l2_subdevice.h @@ -13,6 +13,8 @@ #include "media_object.h" +#include "log.h" + namespace libcamera { struct Rectangle; @@ -23,7 +25,7 @@ struct V4L2SubdeviceFormat { uint32_t height; }; -class V4L2Subdevice +class V4L2Subdevice : protected Loggable { public: explicit V4L2Subdevice(const MediaEntity *entity); @@ -44,6 +46,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 listPadSizes(unsigned int pad, unsigned int mbus_code, std::vector *formats); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a043a07ff156..20439b895b99 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -222,7 +222,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format) ret = -errno; LOG(V4L2Subdev, Error) << "Unable to get format on pad " << pad - << " of " << deviceName() << ": " << strerror(-ret); + << ": " << strerror(-ret); return ret; } @@ -311,8 +311,7 @@ int V4L2Subdevice::listPadSizes(unsigned int pad, unsigned int mbus_code, if (ret && (errno != EINVAL && errno != ENOTTY)) { LOG(V4L2Subdev, Error) << "Unable to enumerate format on pad " << pad - << " of " << deviceName() << ": " - << strerror(errno); + << ": " << strerror(errno); return ret; } @@ -340,7 +339,7 @@ std::vector V4L2Subdevice::listPadFormats(unsigned int pad) if (ret && (errno != EINVAL && errno != ENOTTY)) { LOG(V4L2Subdev, Error) << "Unable to enumerate format on pad " << pad - << " of " << deviceName() << ": " << strerror(-ret); + << ": " << strerror(-ret); return formats; } @@ -380,8 +379,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, ret = -errno; LOG(V4L2Subdev, Error) << "Unable to set rectangle " << target << " on pad " - << pad << " of " << deviceName() << ": " - << strerror(-ret); + << ": " << strerror(-ret); return ret; }