[RFC PATCH v1 3/7] libcamera: base: log: Remove `LogMessage::init()`

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Jan 24 18:01:32 CET 2025


Hi Barnabás,

Thank you for the patch.

On Tue, Jan 21, 2025 at 06:55:56PM +0000, Barnabás Pőcze wrote:
> It is a short function that can be merged into the constructor with
> essentially no change in observable behaviour, so do that.
> 
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  include/libcamera/base/log.h |  2 --
>  src/libcamera/base/log.cpp   | 17 +++++------------
>  2 files changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
> index 620930125..d73aa7913 100644
> --- a/include/libcamera/base/log.h
> +++ b/include/libcamera/base/log.h
> @@ -77,8 +77,6 @@ public:
>  private:
>  	LIBCAMERA_DISABLE_COPY(LogMessage)
>  
> -	void init(const char *fileName, unsigned int line);
> -
>  	std::ostringstream msgStream_;
>  	const LogCategory &category_;
>  	LogSeverity severity_;
> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
> index 1024fed7f..1513e41fb 100644
> --- a/src/libcamera/base/log.cpp
> +++ b/src/libcamera/base/log.cpp
> @@ -876,9 +876,12 @@ const LogCategory &LogCategory::defaultCategory()
>  LogMessage::LogMessage(const char *fileName, unsigned int line,
>  		       const LogCategory &category, LogSeverity severity,
>  		       const std::string &prefix)
> -	: category_(category), severity_(severity), prefix_(prefix)
> +	: category_(category), severity_(severity),
> +	  timestamp_(utils::clock::now()), prefix_(prefix)
>  {
> -	init(fileName, line);
> +	std::ostringstream ossFileInfo;
> +	ossFileInfo << utils::basename(fileName) << ":" << line;
> +	fileInfo_ = std::move(ossFileInfo).str();
>  }
>  
>  /**
> @@ -901,16 +904,6 @@ LogMessage::LogMessage(LogMessage &&other)
>  {
>  }
>  
> -void LogMessage::init(const char *fileName, unsigned int line)
> -{
> -	/* Log the timestamp, severity and file information. */
> -	timestamp_ = utils::clock::now();
> -
> -	std::ostringstream ossFileInfo;
> -	ossFileInfo << utils::basename(fileName) << ":" << line;
> -	fileInfo_ = ossFileInfo.str();
> -}
> -
>  LogMessage::~LogMessage()
>  {
>  	/* Don't print anything if we have been moved to another LogMessage. */

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list