From patchwork Thu Jan 30 19:58:47 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: 22715 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 52A1BBD808 for ; Thu, 30 Jan 2025 19:58:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15B7C68574; Thu, 30 Jan 2025 20:58:55 +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="qFNEtj3p"; 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 3C7406851B for ; Thu, 30 Jan 2025 20:58:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738267132; x=1738526332; bh=wWWSvTBWzUt3mMvSNWgsAgb9RJeXwkMcnIay0f3fFDw=; 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=qFNEtj3pFXJbE81nfEv0YwdU3zrbHZkQivw2L/Ga/0yUwmXZuw/j9l0fj42H041hN EWxXyMElGbmjkKLeP7meTox7jAOCJPZDBTsS1jZVPchOgBfKw/uoz9uqQ4+2Vt8eLl S5QLh3CZWqsWu8iKIKJnD9phE6dUtW2vHK1QNvn7rCBTu3ct0lnFfEIVzaPZuFpqFa bH8/AwvZgtXpFNyFNzzP/mj5Qfkxg/qWY9UnQemwJ9qg9XeereWfKwjSZg25ScQhU/ dLBbRKG9N2S17CWOPmfNMAqg7dLwgcmQ9ZIkNEBDyKxBu7ksbwvWnHdnkkFlzYIceF HH/OYZRIxPbrA== Date: Thu, 30 Jan 2025 19:58:47 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Laurent Pinchart Subject: [RFC PATCH v2 6/9] libcamera: base: log: Pass dynamic prefix through Message-ID: <20250130195811.1230581-7-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: f7c5cdebdb8bce63116dffcb783b8c597c6fea9e 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 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 9415b6937..0dfdb0e9b 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -872,9 +872,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;