[libcamera-devel] [PATCH] libcamera: media_device: Use Loggable interface

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Feb 18 21:15:41 CET 2020


Hi Kieran,

Thanks for your work.

On 2020-02-18 02:07:51 +0200, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Mon, Feb 17, 2020 at 11:48:41PM +0000, Kieran Bingham wrote:
> > Extend MediaDevice to inherit from the Loggable interface to support a
> > logPrefix which presents the device node path, and the driver name.
> > 
> > Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> > ---
> >  src/libcamera/include/media_device.h | 6 +++++-
> >  src/libcamera/media_device.cpp       | 5 +++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> > index 7b88e2875d59..44a59e70139e 100644
> > --- a/src/libcamera/include/media_device.h
> > +++ b/src/libcamera/include/media_device.h
> > @@ -16,11 +16,12 @@
> >  
> >  #include <libcamera/signal.h>
> >  
> > +#include "log.h"
> >  #include "media_object.h"
> >  
> >  namespace libcamera {
> >  
> > -class MediaDevice
> > +class MediaDevice : protected Loggable
> >  {
> >  public:
> >  	MediaDevice(const std::string &deviceNode);
> > @@ -52,6 +53,9 @@ public:
> >  
> >  	Signal<MediaDevice *> disconnected;
> >  
> > +protected:
> > +	std::string logPrefix() const;
> > +
> >  private:
> >  	std::string driver_;
> >  	std::string deviceNode_;
> > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> > index e1ae34f88455..fad475b9ac76 100644
> > --- a/src/libcamera/media_device.cpp
> > +++ b/src/libcamera/media_device.cpp
> > @@ -74,6 +74,11 @@ MediaDevice::~MediaDevice()
> >  	clear();
> >  }
> >  
> > +std::string MediaDevice::logPrefix() const
> > +{
> > +	return deviceNode() + "[" + driver() + "]";
> 
> Before MediaDevice::populate is called, this will print "/dev/mediaX[]".
> I suppose that's not a problem.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

I think it's not a problem and I like the added information added to 
logs from this change.

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> 
> > +}
> > +
> >  /**
> >   * \brief Claim a device for exclusive use
> >   *
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list