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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2022-05-25 18:48:26 +03:00
parent 8a606e6c67
commit 207e52b8d3

View file

@ -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);