From patchwork Tue Feb 25 17:36:10 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: 22876 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 03AAFBDB1C for ; Tue, 25 Feb 2025 17:36:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ABFC868737; Tue, 25 Feb 2025 18:36:16 +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="Q3ibdWN+"; 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 C66A468733 for ; Tue, 25 Feb 2025 18:36:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1740504975; x=1740764175; bh=/noqSu4fVaWgCxSoaRAATgwSqN50IgRkfAlKy4jj8y0=; 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=Q3ibdWN+X1mtu6tlwKrUWdwhfFgkmSFXVdKcPZuvbKSkSFVHEyyMuxRH2NKuUokxz 4N3j5hELYKpiw7nun770wX8eRCM7GhWetZhk5VtseQmBFZqjWHRubKJ7tIq+uKUeWD Pjt//4OUBPg6uQzjwvF3ShsIRxXqVKc9+uAqr2nyt8FXB5+K8CA5yU9ikeDFizSEfa efnL4PbM3GDuSHthIAjenVLn0ZA+kQZDwA6ugz+As6iHS1gm6Nw0fqWnEgt7Apn8kX e2Z/QKy4AhKutoNg1ryXC1Gw7Z3714R2p08bjWV83bpNrAQRAox10G0nK5p00TwTIB VpF3cx5TFVoOA== Date: Tue, 25 Feb 2025 17:36:10 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Laurent Pinchart Subject: [PATCH v4 6/8] libcamera: base: log: Pass dynamic prefix through Message-ID: <20250225173531.2595922-7-pobrn@protonmail.com> In-Reply-To: <20250225173531.2595922-1-pobrn@protonmail.com> References: <20250225173531.2595922-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 7a640fd162f6ea3af5dea77205916449c6e5dabf 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 Reviewed-by: Jacopo Mondi --- 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 acef24203..1fb92603f 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(); std::ostream &stream() { return msgStream_; } diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index c0e0be60f..6687deb93 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)) { }