[PATCH] libcamera: log: Match whole category in LIBCAMERA_LOG_LEVELS
Stefan Klug
stefan.klug at ideasonboard.com
Mon Jan 20 14:30:15 CET 2025
A LIBCAMERA_LOG_LEVELS value of "RkISP1:0" also applies to RkISP1Ccm and
RkISP1Awb. This behavior is unexpected as it automatically enables all
algorithm log categories when the intent is only to increase the log
level of the upper category. Fix that by ensuring that the full name
gets matched. The * wildcard is still supported, so RkISP1* matches
RkISP1 and RkISP1Awb.
Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
---
src/libcamera/base/log.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
index 3a656b8f099f..36e57d6017ab 100644
--- a/src/libcamera/base/log.cpp
+++ b/src/libcamera/base/log.cpp
@@ -718,11 +718,15 @@ void Logger::registerCategory(LogCategory *category)
const std::string &name = category->name();
for (const std::pair<std::string, LogSeverity> &level : levels_) {
+ unsigned int i;
+ bool wildcard = false;
bool match = true;
- for (unsigned int i = 0; i < level.first.size(); ++i) {
- if (level.first[i] == '*')
+ for (i = 0; i < level.first.size(); ++i) {
+ if (level.first[i] == '*') {
+ wildcard = true;
break;
+ }
if (i >= name.size() ||
name[i] != level.first[i]) {
@@ -731,6 +735,10 @@ void Logger::registerCategory(LogCategory *category)
}
}
+ /* Ensure the full name got matched */
+ if (!(wildcard || i == name.size()))
+ continue;
+
if (match) {
category->setSeverity(level.second);
break;
--
2.43.0
More information about the libcamera-devel
mailing list