From patchwork Wed May 25 22:25:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16046 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 BEEADC326D for ; Wed, 25 May 2022 22:25:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5E0465663; Thu, 26 May 2022 00:25:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653517517; bh=BnBM4ZHYsqKV4XZBmPL+ckPipLUUlQcsT4unuHQEajY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eRv37vVQA4iDoNRkiifAaPUcjjM00Q140mfoIqfsn/sRTizYpHFi39FOLxM673CDN JKNke38qcUWc5qt0/F6gjtswrAtMatw2JWmrcZy5mSsu+mt/BjI1hEJHw8rR1bqBf2 A650sbjDVUBzdWof+caucwC+eSCJpe4SHgkO9WIdSl5rP1Fb04QexjFuMLJP7SXtaQ kCY3lrL2gIycA6gxWT1JiRZTtdjBZzc7XKx1SSxGJO66BIS/nVaZ8lfTLDHaB//bIQ rD9wj6lJoAO21O9NlHc8WWgd8qvmJnQGSdP4klMXMqsQGvATUx+BacgPQRK4XZSywk QzYUyTPju72hg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1683B60422 for ; Thu, 26 May 2022 00:25:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="B8ietL3X"; 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 96473D80; Thu, 26 May 2022 00:25:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653517512; bh=BnBM4ZHYsqKV4XZBmPL+ckPipLUUlQcsT4unuHQEajY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8ietL3XnfLtYpBggndBf/GHfbeVizxjENYwsfvjAbdN3sFcuBzVTadgcJ/cx8x8U 2CJtjspmsnfi/92IXa1PBOhwlFx/cVbREHZmy3GonNEs8TE2QJcg1P7P7oce34molm tmHEjEUCepb87t+hh0Pi/2C7+S1WAosBoL5OJcnY= To: libcamera-devel@lists.libcamera.org Date: Thu, 26 May 2022 01:25:01 +0300 Message-Id: <20220525222503.6460-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525222503.6460-1-laurent.pinchart@ideasonboard.com> References: <20220525222503.6460-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: base: log: Log to std::cerr if log file can't be opened 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" If the log file specified through LIBCAMERA_LOG_FILE can't be opened, logging is currently completely disabled. This doesn't match the documented behaviour that tells std::cerr is used instead. Fix it to match the documentation. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- src/libcamera/base/log.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 9ae62368a54d..26f1420703b9 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -517,6 +517,8 @@ void Logger::logSetLevel(const char *category, const char *level) */ Logger::Logger() { + logSetStream(&std::cerr); + parseLogFile(); parseLogLevels(); } @@ -533,10 +535,8 @@ Logger::Logger() void Logger::parseLogFile() { const char *file = utils::secure_getenv("LIBCAMERA_LOG_FILE"); - if (!file) { - logSetStream(&std::cerr); + if (!file) return; - } if (!strcmp(file, "syslog")) { logSetTarget(LoggingTargetSyslog);