[libcamera-devel] [PATCH 3/5] libcamera: base: log: Log to std::cerr if log file can't be opened
paul.elder at ideasonboard.com
paul.elder at ideasonboard.com
Tue May 31 05:29:09 CEST 2022
Hi Laurent,
On Thu, May 26, 2022 at 01:25:01AM +0300, Laurent Pinchart via libcamera-devel wrote:
> 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>
Reviewed-by: Paul Elder <paul.elder 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);
More information about the libcamera-devel
mailing list