From patchwork Tue Jan 21 18:56:11 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: 22607 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 6DFB7BD160 for ; Tue, 21 Jan 2025 18:56:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EDA56855C; Tue, 21 Jan 2025 19:56:17 +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="kjsVaL0v"; dkim-atps=neutral Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3D468503 for ; Tue, 21 Jan 2025 19:56:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1737485775; x=1737744975; bh=cBhOGid0r8VciX/qWugH9YEsNhr4QLNKHtT5Z78Y72c=; h=Date:To:From: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=kjsVaL0vvMbGosX9EdQPsmozdEVHXAwJ9I2f+taJqY23s40yj9PTAXU5fq5Kee6LB bB/8kKEYIcS9EStWg4WPQHVDLIQZUOb54G1Xm5MAHeSGW1Z4v70slCObrzMXX5Iqfz KzDkG8Op9+/i8KtlZ1VfPiQCwTwvh+W/mnodZxOWg91VQLwDVgvKp58k+epHRzK19L Ehv12h4YW4bzSEHWqBPo9jqu11X4C/VylL0g1nritZuHN45lKPqXNKe0dVtyomYYuM kZ5HGIC1r8wSc/xcKFX+kkYTYHznpuAC1LEeAJTSk0A4rFOIUmFitNrrP6BvfG6ls0 zyYec02InricA== Date: Tue, 21 Jan 2025 18:56:11 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1 6/7] libcamera: base: log: Pass dynamic prefix through Message-ID: <20250121185554.301901-4-pobrn@protonmail.com> In-Reply-To: <20250121185554.301901-1-pobrn@protonmail.com> References: <20250121185554.301901-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: b87d09b4fbb4ab77f22944f33f63bc361d8a487e 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" Use move construction to essentially pass through the string returned by `Loggable::logPrefix()` to avoid an unnecessary copy. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- include/libcamera/base/log.h | 2 +- src/libcamera/base/log.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index 9c7775660..ef161bece 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -64,7 +64,7 @@ class LogMessage public: LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity, - const std::string &prefix = std::string()); + std::string prefix = {}); LogMessage(LogMessage &&); ~LogMessage(); diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 78db4990c..6430650ec 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -873,9 +873,9 @@ const LogCategory &LogCategory::defaultCategory() */ LogMessage::LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity, - const std::string &prefix) + std::string prefix) : category_(category), severity_(severity), - timestamp_(utils::clock::now()), prefix_(prefix) + timestamp_(utils::clock::now()), prefix_(std::move(prefix)) { std::ostringstream ossFileInfo; ossFileInfo << utils::basename(fileName) << ":" << line;