[libcamera-devel,0/5] libcamera: Add colors to the log
mbox series

Message ID 20220525222503.6460-1-laurent.pinchart@ideasonboard.com
Headers show
Series
  • libcamera: Add colors to the log
Related show

Message

Laurent Pinchart May 25, 2022, 10:24 p.m. UTC
Hello,

This patch series addresses a shortcoming of libcamera compared to
GStreamer or PipeWire, namely colored logs.

This was attempted by Marco Felsch in "[PATCH] libcamera: log: add
colors to log levels" but suffered from coloring message
unconditionally for streams, regardless of whether the stream was backed
by a TTY, a file or something else.

This turned out impossible to solve automatically (as far as I can tell)
as the C++ stream API doesn't expose the underlying file descriptor.
I've thus taken another approach, by exposing coloring through the
libcamera logger API and only enabling it automatically when logging to
std::cerr. This can be disabled with the new LIBCAMERA_LOG_NO_COLOR
environment variable.

Laurent Pinchart (5):
  libcamera: base: log: Remove unnecessary local variable
  libcamera: base: log: Replace stderr with std::cerr in documentation
  libcamera: base: log: Log to std::cerr if log file can't be opened
  libcamera: base: log: Add coloring to the log output
  libcamera: base: log: Color the log prefix

 Documentation/environment_variables.rst |  21 ++-
 include/libcamera/base/log.h            |   5 +-
 include/libcamera/logging.h             |   4 +-
 src/libcamera/base/log.cpp              | 168 +++++++++++++++++-------
 src/libcamera/camera_manager.cpp        |   2 +-
 5 files changed, 144 insertions(+), 56 deletions(-)


base-commit: 3e7f54a3128d8143afb200d626d3b208d493623a