[libcamera-devel] [PATCH] libcamera: log: add colors to log levels
Marian Cichy
m.cichy at pengutronix.de
Wed Feb 3 19:17:46 CET 2021
mono-colored wall of logs can be hard to read and doesn't show the level
of failure at a first glance. By adding colors to the log level
categories, it is much easier to scroll through logs and find important
entries.
---
src/libcamera/log.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 45c7c2d2..3ad9c3de 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -85,11 +85,11 @@ static int log_severity_to_syslog(LogSeverity severity)
static const char *log_severity_name(LogSeverity severity)
{
static const char *const names[] = {
- "DEBUG",
- " INFO",
- " WARN",
- "ERROR",
- "FATAL",
+ "\033[1m\033[37mDEBUG\033[0m",
+ "\033[1m\033[32m INFO\033[0m",
+ "\033[1m\033[33m WARN\033[0m",
+ "\033[1m\033[31mERROR\033[0m",
+ "\033[1m\033[35mFATAL\033[0m",
};
if (static_cast<unsigned int>(severity) < std::size(names))
--
2.20.1
More information about the libcamera-devel
mailing list