From 575703894624306950c0540182afc48ba3732f8c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 3 Feb 2021 19:17:46 +0100 Subject: libcamera: base: log: Add coloring to the log output Extend the logger to support coloring messages. The log level is colorized with per-level colors, and the category with a fixed color. This makes the log output more readable. Coloring is enabled by default when logging to std::cerr, and can be disabled by setting the LIBCAMERA_LOG_NO_COLOR environment variable. When logging to a file with LIBCAMERA_LOG_FILE, coloring is disabled. It can be enabled for file logging using the logSetFile() function. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- include/libcamera/logging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/logging.h b/include/libcamera/logging.h index c36882b9..cd842f67 100644 --- a/include/libcamera/logging.h +++ b/include/libcamera/logging.h @@ -16,8 +16,8 @@ enum LoggingTarget { LoggingTargetStream, }; -int logSetFile(const char *path); -int logSetStream(std::ostream *stream); +int logSetFile(const char *path, bool color = false); +int logSetStream(std::ostream *stream, bool color = false); int logSetTarget(LoggingTarget target); void logSetLevel(const char *category, const char *level); -- cgit v1.2.1