Message ID | 20190226162641.12116-9-jacopo@jmondi.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, On 26/02/2019 16:26, Jacopo Mondi wrote: > Prefix the V4L2Subdevice error messages with the name of the entity. > Remove the manually printed name from log messages where it was used. This will certainly make it easier to keep log lines tied to a specific instance. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> > --- > 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() + "'"; } The quotes feel a bit extraneous here? > + > private: > int listPadSizes(unsigned int pad, unsigned int mbus_code, > std::vector<V4L2SubdeviceFormat> *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<V4L2SubdeviceFormat> 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; > } > >
Hi Jacopo, Thank you for the patch. On Tue, Feb 26, 2019 at 05:26:41PM +0100, Jacopo Mondi wrote: > 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 <jacopo@jmondi.org> > --- > 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" > + This should go above the media_object.h include without any blank line in between. > 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() + "'"; } This will end up inlining two + operations between strings for every call. Let's not make it an inline function. Apart from that, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + > private: > int listPadSizes(unsigned int pad, unsigned int mbus_code, > std::vector<V4L2SubdeviceFormat> *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<V4L2SubdeviceFormat> 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; > } >
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<V4L2SubdeviceFormat> *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<V4L2SubdeviceFormat> 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; }
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 <jacopo@jmondi.org> --- src/libcamera/include/v4l2_subdevice.h | 7 ++++++- src/libcamera/v4l2_subdevice.cpp | 10 ++++------ 2 files changed, 10 insertions(+), 7 deletions(-)