From patchwork Wed May 25 22:24:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16043 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4A564BD161 for ; Wed, 25 May 2022 22:25:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ADBE65666; Thu, 26 May 2022 00:25:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653517513; bh=5KpJwGi0oVwG4VCkaLwIuZzkC1VI3uj+O0EO8iTBQRk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=3uoY4GgqNaCxr75UIWWai3TsC3RRNk2UuQbNEctqgS8cd3/bUku6p9s4uJmqA3C22 /f1ayvVf1nodT710eehQi5f5cekTY45QLr9ggC6o1zTH6ZRFFxkkwYSuyiRhFWKYBT McJyN0tbInatnbXeycdokBIyQnj+lZllwHSrPIwpy3CDGGlx0kgpQFw+4BXDzuV3GG RLcjl53crVDFLXE4hK0S4pVqWI+bp3171xpIq/83NoWtGrSkuzLbDquWHa0xaj+g0c CyCKLCqB1rjPRQVi5/1Ebt63UyLCkie1UTTkXRYQMXDlvfG9PmVs5Nkz0W/EBl3QLb Grbnbacyvsq0g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A52A660422 for ; Thu, 26 May 2022 00:25:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fPAyn+iD"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (ip-109-40-242-63.web.vodafone.de [109.40.242.63]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E0B67563; Thu, 26 May 2022 00:25:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653517511; bh=5KpJwGi0oVwG4VCkaLwIuZzkC1VI3uj+O0EO8iTBQRk=; h=From:To:Cc:Subject:Date:From; b=fPAyn+iD2OXlav3zsk3JO+rDAbi+KQrFRyai+za1IkB66YtbSVvc8lxcZtjwgyota 0c72cDPFecOyJV91LaltggotRB6I+YseazhA8zkcmVACoh0Ne3YY2oCvESJ39u3TtB kok+FMJI0Tg2UBRLwCzTWRQbJhHVwLqwVJQWSzz4= To: libcamera-devel@lists.libcamera.org Date: Thu, 26 May 2022 01:24:58 +0300 Message-Id: <20220525222503.6460-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/5] libcamera: Add colors to the log X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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