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 --- Documentation/environment_variables.rst | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Documentation') diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst index fa703a72..0a7760cb 100644 --- a/Documentation/environment_variables.rst +++ b/Documentation/environment_variables.rst @@ -19,6 +19,9 @@ LIBCAMERA_LOG_LEVELS Example value: ``*:DEBUG`` +LIBCAMERA_LOG_NO_COLOR + Disable coloring of log messages (`more `__). + LIBCAMERA_IPA_CONFIG_PATH Define custom search locations for IPA configurations (`more `__). @@ -40,12 +43,20 @@ Further details Notes about debugging ~~~~~~~~~~~~~~~~~~~~~ -The environment variables ``LIBCAMERA_LOG_FILE`` and ``LIBCAMERA_LOG_LEVELS`` -are used to modify the destination and verbosity of messages provided by -libcamera. +The environment variables ``LIBCAMERA_LOG_FILE``, ``LIBCAMERA_LOG_LEVELS`` and +``LIBCAMERA_LOG_NO_COLOR`` are used to modify the default configuration of the +libcamera logger. + +By default, libcamera logs all messages to the standard error (std::cerr). +Messages are colored by default depending on the log level. Coloring can be +disabled by setting the ``LIBCAMERA_LOG_NO_COLOR`` environment variable. + +The default log destination can also be directed to a file by setting the +``LIBCAMERA_LOG_FILE`` environment variable to the log file name. This also +disables coloring. -The ``LIBCAMERA_LOG_LEVELS`` variable accepts a comma-separated list of -'category:level' pairs. +Log levels are controlled through the ``LIBCAMERA_LOG_LEVELS`` variable, which +accepts a comma-separated list of 'category:level' pairs. The `level `__ part is mandatory and can either be specified by name or by numerical index associated with each level. -- cgit v1.2.1