[{"id":33262,"web_url":"https://patchwork.libcamera.org/comment/33262/","msgid":"<eufyv2melg2nem5b5kzamekid5gfi6ybs2br3ydpatjgadfodh@j3h2fhfeqsev>","date":"2025-02-03T16:30:37","subject":"Re: [RFC PATCH v2 3/9] libcamera: base: log: Remove\n\t`LogMessage::init()`","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Jan 30, 2025 at 07:58:29PM +0000, Barnabás Pőcze wrote:\n> It is a short function that can be merged into the constructor with\n> essentially no change in observable behaviour, so do that.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/base/log.h |  2 --\n>  src/libcamera/base/log.cpp   | 13 +++----------\n>  2 files changed, 3 insertions(+), 12 deletions(-)\n>\n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index b3050eedb..6d2c93019 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -75,8 +75,6 @@ public:\n>  private:\n>  \tLIBCAMERA_DISABLE_COPY_AND_MOVE(LogMessage)\n>\n> -\tvoid init(const char *fileName, unsigned int line);\n> -\n>  \tstd::ostringstream msgStream_;\n>  \tconst LogCategory &category_;\n>  \tLogSeverity severity_;\n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 31053aee1..51a5cd470 100644\n> --- a/src/libcamera/base/log.cpp\n> +++ b/src/libcamera/base/log.cpp\n> @@ -875,19 +875,12 @@ const LogCategory &LogCategory::defaultCategory()\n>  LogMessage::LogMessage(const char *fileName, unsigned int line,\n>  \t\t       const LogCategory &category, LogSeverity severity,\n>  \t\t       const std::string &prefix)\n> -\t: category_(category), severity_(severity), prefix_(prefix)\n> +\t: category_(category), severity_(severity),\n> +\t  timestamp_(utils::clock::now()), prefix_(prefix)\n>  {\n> -\tinit(fileName, line);\n> -}\n> -\n> -void LogMessage::init(const char *fileName, unsigned int line)\n> -{\n> -\t/* Log the timestamp, severity and file information. */\n> -\ttimestamp_ = utils::clock::now();\n> -\n>  \tstd::ostringstream ossFileInfo;\n>  \tossFileInfo << utils::basename(fileName) << \":\" << line;\n> -\tfileInfo_ = ossFileInfo.str();\n> +\tfileInfo_ = std::move(ossFileInfo).str();\n\nWhat is the benefit of moving ossFileInfo first and then calling ::str()\n(which anyway returns a copy to the underlying string) ?\n\n>  }\n>\n>  LogMessage::~LogMessage()\n> --\n> 2.48.1\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0E835C3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 16:30:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 244AD68598;\n\tMon,  3 Feb 2025 17:30:43 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72D296857A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 17:30:41 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 86186D90;\n\tMon,  3 Feb 2025 17:29:29 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"U7swV9uq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738600169;\n\tbh=RlUsB0r9GRCrHHhd/fjxbXnCvLvORkntKb4YEus+ZXg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=U7swV9uq4XlMD+nBXrsoDcvG+lPHuKctE8MiALvIuq6uW3zqizod+CMPnJ2spmrZF\n\tSQ6Op7ViaNAAjRC7yJut7o7bt7jUD7fMzer7EroSsQzvXhIL9glB/BO+nsZyfHiR7+\n\trY3Pypy+63mCLcDmcFKdhgLk+F+zvXR/llGPgLzw=","Date":"Mon, 3 Feb 2025 17:30:37 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 3/9] libcamera: base: log: Remove\n\t`LogMessage::init()`","Message-ID":"<eufyv2melg2nem5b5kzamekid5gfi6ybs2br3ydpatjgadfodh@j3h2fhfeqsev>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-4-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250130195811.1230581-4-pobrn@protonmail.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33271,"web_url":"https://patchwork.libcamera.org/comment/33271/","msgid":"<YOBWbAXMZ9EhB1laFGu3c0xmGHEYt7AupnSLPMtdf6h1uI3O3E6X3f8h6Htp4jqEpDM9b2HQr4BBvul_WkotNjmVvMeQYFZgcewo6DR6VZA=@protonmail.com>","date":"2025-02-03T18:15:00","subject":"Re: [RFC PATCH v2 3/9] libcamera: base: log: Remove\n\t`LogMessage::init()`","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"2025. február 3., hétfő 17:30 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n\n> Hi Barnabás\n> \n> On Thu, Jan 30, 2025 at 07:58:29PM +0000, Barnabás Pőcze wrote:\n> > It is a short function that can be merged into the constructor with\n> > essentially no change in observable behaviour, so do that.\n> >\n> > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/base/log.h |  2 --\n> >  src/libcamera/base/log.cpp   | 13 +++----------\n> >  2 files changed, 3 insertions(+), 12 deletions(-)\n> >\n> > diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> > index b3050eedb..6d2c93019 100644\n> > --- a/include/libcamera/base/log.h\n> > +++ b/include/libcamera/base/log.h\n> > @@ -75,8 +75,6 @@ public:\n> >  private:\n> >  \tLIBCAMERA_DISABLE_COPY_AND_MOVE(LogMessage)\n> >\n> > -\tvoid init(const char *fileName, unsigned int line);\n> > -\n> >  \tstd::ostringstream msgStream_;\n> >  \tconst LogCategory &category_;\n> >  \tLogSeverity severity_;\n> > diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> > index 31053aee1..51a5cd470 100644\n> > --- a/src/libcamera/base/log.cpp\n> > +++ b/src/libcamera/base/log.cpp\n> > @@ -875,19 +875,12 @@ const LogCategory &LogCategory::defaultCategory()\n> >  LogMessage::LogMessage(const char *fileName, unsigned int line,\n> >  \t\t       const LogCategory &category, LogSeverity severity,\n> >  \t\t       const std::string &prefix)\n> > -\t: category_(category), severity_(severity), prefix_(prefix)\n> > +\t: category_(category), severity_(severity),\n> > +\t  timestamp_(utils::clock::now()), prefix_(prefix)\n> >  {\n> > -\tinit(fileName, line);\n> > -}\n> > -\n> > -void LogMessage::init(const char *fileName, unsigned int line)\n> > -{\n> > -\t/* Log the timestamp, severity and file information. */\n> > -\ttimestamp_ = utils::clock::now();\n> > -\n> >  \tstd::ostringstream ossFileInfo;\n> >  \tossFileInfo << utils::basename(fileName) << \":\" << line;\n> > -\tfileInfo_ = ossFileInfo.str();\n> > +\tfileInfo_ = std::move(ossFileInfo).str();\n> \n> What is the benefit of moving ossFileInfo first and then calling ::str()\n> (which anyway returns a copy to the underlying string) ?\n\nOops, this is an unrelated change from my experimentation. In C++20 and later\none is able to move the string out of a stringstream without copying. Before\nthat there is no effect.\n\n\n> \n> >  }\n> >\n> >  LogMessage::~LogMessage()\n> > --\n> > 2.48.1\n> >\n> >\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1553FC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 18:15:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 130856859D;\n\tMon,  3 Feb 2025 19:15:06 +0100 (CET)","from mail-40133.protonmail.ch (mail-40133.protonmail.ch\n\t[185.70.40.133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CF50D61876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 19:15:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"q45GWDud\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738606504; x=1738865704;\n\tbh=3glVc2DYe9vDp4/dlh96cfz5aJWNeQ/vpBQ1tEej0EE=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=q45GWDudTOQ0TTYBaeimJXPiWKRtgri8noBirhleWWEkNIglgNi1Q3jg+ccwFXYkX\n\tuiutLQSftgLruxt8hmgglHqdkObZX7P547Rv73S+0dVq0ZrwtQCsq34o2ZU/hsIYll\n\tix47059zBiFbzDvej/lBRfGIoVCE/IY0IFTLz1zJOvJAEQtMGSBIFV8Sgbkd4xg9j+\n\tp7XAJwaItI4rnTudXfjt6BmVqNSpuiXWsix59OqmVXL8yPTeBQqDApH4gYzdyR+e18\n\tCgTX/LpXr9s01XWugv1QC6ecTQaCPIYbvoZat6fkxbmHDAM4LQZszJgdf5DaW4uUOx\n\t3J+RTGLM4Buxg==","Date":"Mon, 03 Feb 2025 18:15:00 +0000","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [RFC PATCH v2 3/9] libcamera: base: log: Remove\n\t`LogMessage::init()`","Message-ID":"<YOBWbAXMZ9EhB1laFGu3c0xmGHEYt7AupnSLPMtdf6h1uI3O3E6X3f8h6Htp4jqEpDM9b2HQr4BBvul_WkotNjmVvMeQYFZgcewo6DR6VZA=@protonmail.com>","In-Reply-To":"<eufyv2melg2nem5b5kzamekid5gfi6ybs2br3ydpatjgadfodh@j3h2fhfeqsev>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-4-pobrn@protonmail.com>\n\t<eufyv2melg2nem5b5kzamekid5gfi6ybs2br3ydpatjgadfodh@j3h2fhfeqsev>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"a81b38747fa822f1d8790d0094563ffbc932ede3","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]