diff --git a/core/options.cpp b/core/options.cpp index cb27046b..41801ae8 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -201,8 +201,10 @@ bool Options::Parse(int argc, char *argv[]) set_subdev_hdr_ctrl(0); app_->initCameraManager(); + bool log_env_set = getenv("LIBCAMERA_LOG_LEVELS"); // Unconditionally set the logging level to error for a bit. - libcamera::logSetLevel("*", "ERROR"); + if (!log_env_set) + libcamera::logSetLevel("*", "ERROR"); std::vector> cameras = app_->GetCameras(); if (camera < cameras.size()) @@ -342,7 +344,7 @@ bool Options::Parse(int argc, char *argv[]) } // Reset log level to Info. - if (verbose) + if (verbose && !log_env_set) libcamera::logSetLevel("*", "INFO"); // Set the verbosity diff --git a/core/rpicam_app.cpp b/core/rpicam_app.cpp index 5268a4d6..cd5a7c05 100644 --- a/core/rpicam_app.cpp +++ b/core/rpicam_app.cpp @@ -216,9 +216,13 @@ void RPiCamApp::OpenCamera() std::unique_ptr config = camera_->generateConfiguration({ libcamera::StreamRole::Raw }); const libcamera::StreamFormats &formats = config->at(0).formats(); + bool log_env_set = getenv("LIBCAMERA_LOG_LEVELS"); // Suppress log messages when enumerating camera modes. - libcamera::logSetLevel("RPI", "ERROR"); - libcamera::logSetLevel("Camera", "ERROR"); + if (!log_env_set) + { + libcamera::logSetLevel("RPI", "ERROR"); + libcamera::logSetLevel("Camera", "ERROR"); + } for (const auto &pix : formats.pixelformats()) { @@ -242,8 +246,11 @@ void RPiCamApp::OpenCamera() } } - libcamera::logSetLevel("RPI", "INFO"); - libcamera::logSetLevel("Camera", "INFO"); + if (!log_env_set) + { + libcamera::logSetLevel("RPI", "INFO"); + libcamera::logSetLevel("Camera", "INFO"); + } } void RPiCamApp::CloseCamera()