From patchwork Mon Feb 17 18:55:02 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: 22806 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 70BA6C3200 for ; Mon, 17 Feb 2025 18:55:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2129C68696; Mon, 17 Feb 2025 19:55:10 +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="Y7pOS9Hq"; dkim-atps=neutral Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B7276868D for ; Mon, 17 Feb 2025 19:55:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1739818507; x=1740077707; bh=FV4vPqZlU6kReFob6wa3fv269jNCccPDdKLA4RCB100=; 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=Y7pOS9HqTiFEuBl2IjRIlb0GT/rj4RkqMGzELVpAHYSM1Mr8pAE8+SqsfkLl+e+ZV 7udH0CXMf19ozD6CXpWKsNcjO/z0kd+jf4K1r8S83InVrKzUvLuVy+8z9KZ9LsNMAr EMWUqAlsW3t47A0BKk9uCrQB8O8bQacxILdOAANOvG9yd2qasxoFm34OP41zqc6EBv 0dGU3/xCKZ5lv3/5dYKxWmPEke7vxX6ckVHMMKoi9frfUTa74+EX8TWWaMhGrV009r JpqzxkIqLo90Y64ybhr3W+9VRpkxoAmzkIi55KdNzCpNRTG2PaqT2CyGoRdQoijCIh c3cymiP/MdVuQ== Date: Mon, 17 Feb 2025 18:55:02 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Laurent Pinchart Subject: [PATCH v3 6/8] libcamera: base: log: Pass dynamic prefix through Message-ID: <20250217185433.306833-7-pobrn@protonmail.com> In-Reply-To: <20250217185433.306833-1-pobrn@protonmail.com> References: <20250217185433.306833-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 86fd220242882396c841d43bb447aa34fa478d82 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 353520e10..195426c41 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(); [[nodiscard]] std::ostream &stream() { return msgStream_; } diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 55019def8..2c233be36 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -858,11 +858,11 @@ 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()), fileInfo_((std::ostringstream() << utils::basename(fileName) << ":" << line).str()), - prefix_(prefix) + prefix_(std::move(prefix)) { }