From patchwork Thu Jun 2 07:34:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16131 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 DB752BD160 for ; Thu, 2 Jun 2022 07:34:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 206BB6563A; Thu, 2 Jun 2022 09:34:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654155254; bh=qxBEWvky3It78t0jnk2tx+cvpoQ1vq5ATuk60hzgJqc=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BBmfiqcnGWvaDP6aU/yAXmkTt8yeXK4tyKBhqE5jT0NudKYx7sZerpeG36l18vDdT 5qyyZ3zXosm9h1fwYvl1Ca+J3GJKoZqicQ5ZFy27Tr/6UaWX6Ax7gtwGAisUyAX4NJ eJgxSOtWsWTt0l5wMpMA6YcB86nHK6VAOClTH4nLJ4nc9zh+OzgGKSBtH86JbGINkv IzLX7XzpVpIGWMzCsDsQcQZk5I47aK4ZprGKrNutOr5BfsTSnYECrF3mGPd1pYehEn dD1VpFRZjbzU3JlAL2E2C6LFEg6iJ7cqaFEs3r2zCsiz4qXZf//ixZODbaPhsgQB9o NE8B+jhXEJxUQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F32D96040E for ; Thu, 2 Jun 2022 09:34:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lTmXUkAX"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (lmontsouris-659-1-41-236.w92-154.abo.wanadoo.fr [92.154.76.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AA7866BD for ; Thu, 2 Jun 2022 09:34:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1654155252; bh=qxBEWvky3It78t0jnk2tx+cvpoQ1vq5ATuk60hzgJqc=; h=From:To:Subject:Date:From; b=lTmXUkAXsdzL3glcpCkor9xOoyGXKk0MYp4Tmi3pMLATvvaK1nCtdbPTzNA9xMQPw bj8K8jA8aNxI0/qaHZ7fU/mmSjJ9Hi2s74v8f06JKKOwHL3AebcZpUehQZLNqSf9Sg EQhp2HwynGMnsgXvp/+Kmbc6kbCx1767xkCEyWMk= To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Jun 2022 10:34:03 +0300 Message-Id: <20220602073405.28168-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 0/2] 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. Compared to v1, the first 3 patch have already been merged and are thus not included in this version. The most notable other change is in patch 1/2, where the escape codes used for bright colors have changed to work with minicom. Laurent Pinchart (2): 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 | 144 ++++++++++++++++++------ 4 files changed, 131 insertions(+), 43 deletions(-) base-commit: dfcf638a0a6d26dbfab5348e646e5cb3c45ec51e Reviewed-by: Kieran Bingham