[v2,3/5] libcamera: base: log: Do not check severity before printing
diff mbox series

Message ID 20260119113104.3560802-4-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: base: log: Do not instantiate disabled `LogMessage`s
Related show

Commit Message

Barnabás Pőcze Jan. 19, 2026, 11:31 a.m. UTC
Now that the severity of the log message and the category is compared in
the expansion of the `LOG()` macro, there is no need to do it again in the
destructor.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/base/log.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Kieran Bingham Jan. 19, 2026, 12:52 p.m. UTC | #1
Quoting Barnabás Pőcze (2026-01-19 11:31:01)
> Now that the severity of the log message and the category is compared in
> the expansion of the `LOG()` macro, there is no need to do it again in the
> destructor.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/base/log.cpp | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
> index 6e6d2887c..da45b0d65 100644
> --- a/src/libcamera/base/log.cpp
> +++ b/src/libcamera/base/log.cpp
> @@ -867,8 +867,7 @@ LogMessage::~LogMessage()
>  
>         msgStream_ << std::endl;
>  
> -       if (severity_ >= category_.severity())
> -               logger->write(*this);
> +       logger->write(*this);
>  
>         if (severity_ == LogSeverity::LogFatal) {
>                 logger->backtrace();
> -- 
> 2.52.0
>

Patch
diff mbox series

diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
index 6e6d2887c..da45b0d65 100644
--- a/src/libcamera/base/log.cpp
+++ b/src/libcamera/base/log.cpp
@@ -867,8 +867,7 @@  LogMessage::~LogMessage()
 
 	msgStream_ << std::endl;
 
-	if (severity_ >= category_.severity())
-		logger->write(*this);
+	logger->write(*this);
 
 	if (severity_ == LogSeverity::LogFatal) {
 		logger->backtrace();