From patchwork Tue Jan 21 18:55:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22604 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 8D3B5BD160 for ; Tue, 21 Jan 2025 18:56:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B3B0A68503; Tue, 21 Jan 2025 19:56:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="TJxPIzIa"; dkim-atps=neutral Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0DD1860380 for ; Tue, 21 Jan 2025 19:56:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1737485763; x=1737744963; bh=inYsCoT9BMm1Qo17lhRjtpTS9yz04iQOJCGsmUDqf+g=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=TJxPIzIa5w5578ZByJWJ34edO5Oai6TQtSZINB3/frn4X6pvNHbhQrd8xQ/PtDjJn MmT/7lFzmr9+pHVBHsdj5CqlCBBjHrr6ik0aBuNfjSAuCgDm7Z3ddVn8uSetQcJRZX WIOmuDNrcroOaz0OqR9XU2cm7gHBa1+Hn3AMHKNO/j14V9uez0r2SCHyqXLB4gbW5I AH90vqpf/buocljFlO7W51TE3Y2UopZasFVCB9ihSV658M2E9fqKQ+gcn3U+Jz2wI/ Z0hQ9TbDp6pgvko9fRHavuDR5gGJGBEoXJiWU0J8EmLW7q5IGQSg69LRknBrvggTrf 46xNPmvG3wRCQ== Date: Tue, 21 Jan 2025 18:55:56 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1 3/7] libcamera: base: log: Remove `LogMessage::init()` Message-ID: <20250121185554.301901-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: d93e837d6a92c0de7f7a3d770ff826e6bece2bf7 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" It is a short function that can be merged into the constructor with essentially no change in observable behaviour, so do that. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- include/libcamera/base/log.h | 2 -- src/libcamera/base/log.cpp | 17 +++++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index 620930125..d73aa7913 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -77,8 +77,6 @@ public: private: LIBCAMERA_DISABLE_COPY(LogMessage) - void init(const char *fileName, unsigned int line); - std::ostringstream msgStream_; const LogCategory &category_; LogSeverity severity_; diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 1024fed7f..1513e41fb 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -876,9 +876,12 @@ const LogCategory &LogCategory::defaultCategory() LogMessage::LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity, const std::string &prefix) - : category_(category), severity_(severity), prefix_(prefix) + : category_(category), severity_(severity), + timestamp_(utils::clock::now()), prefix_(prefix) { - init(fileName, line); + std::ostringstream ossFileInfo; + ossFileInfo << utils::basename(fileName) << ":" << line; + fileInfo_ = std::move(ossFileInfo).str(); } /** @@ -901,16 +904,6 @@ LogMessage::LogMessage(LogMessage &&other) { } -void LogMessage::init(const char *fileName, unsigned int line) -{ - /* Log the timestamp, severity and file information. */ - timestamp_ = utils::clock::now(); - - std::ostringstream ossFileInfo; - ossFileInfo << utils::basename(fileName) << ":" << line; - fileInfo_ = ossFileInfo.str(); -} - LogMessage::~LogMessage() { /* Don't print anything if we have been moved to another LogMessage. */