From 207e52b8d35e1684df20c65fe379d46bee442987 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 25 May 2022 18:48:26 +0300 Subject: libcamera: base: log: Log to std::cerr if log file can't be opened 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 Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- 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 9ae62368..26f14207 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); -- cgit v1.2.1