From de0a8beecea80a5cf79ad43f18c1e1945b19753d Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Fri, 14 Jun 2024 20:53:13 +0400 Subject: [PATCH] [base] add WriteLog to the LogHelper to compose log message Signed-off-by: Kiryl Kaveryn --- base/logging.cpp | 7 ++++++- base/logging.hpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/base/logging.cpp b/base/logging.cpp index a72bf6325c..ea511d1074 100644 --- a/base/logging.cpp +++ b/base/logging.cpp @@ -64,6 +64,11 @@ void LogHelper::WriteProlog(std::ostream & s, LogLevel level) s << GetLogLevelNames()[level] << '(' << GetThreadID() << ") " << std::fixed << std::setprecision(5) << sec << ' '; } +void LogHelper::WriteLog(std::ostream & s, SrcPoint const & srcPoint, std::string const & msg) +{ + s << DebugPrint(srcPoint) << msg << std::endl; +} + void LogMessageDefault(LogLevel level, SrcPoint const & srcPoint, std::string const & msg) { auto & logger = LogHelper::Instance(); @@ -71,8 +76,8 @@ void LogMessageDefault(LogLevel level, SrcPoint const & srcPoint, std::string co std::lock_guard lock(g_logMutex); logger.WriteProlog(out, level); + logger.WriteLog(out, srcPoint, msg); - out << DebugPrint(srcPoint) << msg << std::endl; std::cerr << out.str(); CHECK_LESS(level, g_LogAbortLevel, ("Abort. Log level is too serious", level)); diff --git a/base/logging.hpp b/base/logging.hpp index a0ee7fb32c..d7bd8171d5 100644 --- a/base/logging.hpp +++ b/base/logging.hpp @@ -31,6 +31,7 @@ public: int GetThreadID(); void WriteProlog(std::ostream & s, LogLevel level); + static void WriteLog(std::ostream & s, SrcPoint const & srcPoint, std::string const & msg); private: int m_threadsCount{0};