From dce4d230c52978fc258ee3bc31117389d9c25388 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 3 Apr 2024 10:52:39 -0700 Subject: Make flush explicit A more in depth explanation of this is here[1], but being explicit flushing the buffer (using std::flush) captures intent better here, which we intend a newline, then a flush. Keeping those as separate captures the intended behavior. Tested: Launching bmcweb shows logging statements still function. [1] https://clang.llvm.org/extra/clang-tidy/checks/performance/avoid-endl.html Change-Id: I6aa427f4e4134ce30ce552cbfdd5d7be3df56c47 Signed-off-by: Ed Tanous --- http/logging.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'http') diff --git a/http/logging.hpp b/http/logging.hpp index 781bcfb9b2..0ed47771c4 100644 --- a/http/logging.hpp +++ b/http/logging.hpp @@ -196,7 +196,8 @@ inline void vlog(const FormatString& format, std::format_args&& args) filename = filename.substr(filename.rfind('/') + 1); std::cout << std::format("[{} {}:{}] ", levelString, filename, format.loc.line()) - << std::vformat(format.str, args) << std::endl; + << std::vformat(format.str, args) << '\n' + << std::flush; } } // namespace crow -- cgit v1.2.3