From patchwork Thu Jan 30 19:58:29 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: 22712 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 54D6EBD808 for ; Thu, 30 Jan 2025 19:58:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 052466856F; Thu, 30 Jan 2025 20:58:36 +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="m5pQN/lb"; dkim-atps=neutral Received: from mail-10631.protonmail.ch (mail-10631.protonmail.ch [79.135.106.31]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CADF86851B for ; Thu, 30 Jan 2025 20:58:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738267113; x=1738526313; bh=oTBK7RJ1NZawKYjOPU9CPCk4DQ19ntVzH0LoVi2ujRc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=m5pQN/lbczLqul8GlwoGI6NRIRSkomiOFxsmfzJFJYFgMD+grz8byUQ149nHRkmRS ef/IxhPpBxXLwa48d+wP/j02yExwJuX6ghzmCzwfHimDEST8rnMx9gYka/k1rfwSTV MbQLWYwMdAgMwcEpm3xSGiqI94gHpflar1gYcSLRMYrH4RONlxWpxv5SpBRp8jONwO dTATfHem0p37YbZdMbLyKNErbZd5llgyeswPkQYXBVe6a5+mGyyDQNsv3QgkkSUSDl NoxChqkCnELHwiVLUf7PyFAd32JE3nHbioCjrMSHe68JGVyG3+p0Cia2OYMx7eCXzK eDTnQ8nDvS97w== Date: Thu, 30 Jan 2025 19:58:29 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Laurent Pinchart Subject: [RFC PATCH v2 3/9] libcamera: base: log: Remove `LogMessage::init()` Message-ID: <20250130195811.1230581-4-pobrn@protonmail.com> In-Reply-To: <20250130195811.1230581-1-pobrn@protonmail.com> References: <20250130195811.1230581-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: d10034f6c9556a43ba3149076683d15dd6c345b6 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 | 13 +++---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index b3050eedb..6d2c93019 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -75,8 +75,6 @@ public: private: LIBCAMERA_DISABLE_COPY_AND_MOVE(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 31053aee1..51a5cd470 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -875,19 +875,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); -} - -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(); + fileInfo_ = std::move(ossFileInfo).str(); } LogMessage::~LogMessage()