[libcamera-devel] [PATCH 3/5] libcamera: base: log: Log to std::cerr if log file can't be opened

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu May 26 00:25:01 CEST 2022


If the log file specified through LIBCAMERA_LOG_FILE can't be opened,
logging is currently completely disabled. This doesn't match the
documented behaviour that tells std::cerr is used instead. Fix it to
match the documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/libcamera/base/log.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
index 9ae62368a54d..26f1420703b9 100644
--- a/src/libcamera/base/log.cpp
+++ b/src/libcamera/base/log.cpp
@@ -517,6 +517,8 @@ void Logger::logSetLevel(const char *category, const char *level)
  */
 Logger::Logger()
 {
+	logSetStream(&std::cerr);
+
 	parseLogFile();
 	parseLogLevels();
 }
@@ -533,10 +535,8 @@ Logger::Logger()
 void Logger::parseLogFile()
 {
 	const char *file = utils::secure_getenv("LIBCAMERA_LOG_FILE");
-	if (!file) {
-		logSetStream(&std::cerr);
+	if (!file)
 		return;
-	}
 
 	if (!strcmp(file, "syslog")) {
 		logSetTarget(LoggingTargetSyslog);
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list