[libcamera-devel] [PATCH] libcamera: log: add colors to log levels

Sebastian Fricke sebastian.fricke at posteo.net
Wed Feb 3 20:30:26 CET 2021


On 03.02.2021 20:13, Marian Cichy wrote:
>Hi Sebastian,
>
>thanks, I also just realized that I probably should sign-off, right?
>
>should I send a V2?

I would probably not send it right away and wait for some feedback from
the others first.

Greetings,
Sebastian

>
>regards,
>
>marian
>
>On 2/3/21 8:09 PM, Sebastian Fricke wrote:
>>Hey Marian,
>>
>>Thank you for the patch.
>>This looks better than before, I tested it on my machine and it worked
>>without problems.
>>If you like to you can add:
>>Tested-by: Sebastian Fricke <sebastian.fricke at posteo.net>
>>
>>Greetings,
>>Sebastian
>>
>>On 03.02.2021 19:17, Marian Cichy wrote:
>>>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
>>>
>>>_______________________________________________
>>>libcamera-devel mailing list
>>>libcamera-devel at lists.libcamera.org
>>>https://lists.libcamera.org/listinfo/libcamera-devel
>>_______________________________________________
>>libcamera-devel mailing list
>>libcamera-devel at lists.libcamera.org
>>https://lists.libcamera.org/listinfo/libcamera-devel
>>


More information about the libcamera-devel mailing list