From 9fbbb2523cac1c5b73eb64987a06e3570cabbaba Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 28 Aug 2024 15:57:28 -0500 Subject: [PATCH 1/2] Remove flushes and fix tests Signed-off-by: Addisu Z. Taddese --- include/gz/common/Console.hh | 5 ++--- src/Console.cc | 6 ++---- src/Console_TEST.cc | 20 -------------------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/include/gz/common/Console.hh b/include/gz/common/Console.hh index 48aa5523..e99333a4 100644 --- a/include/gz/common/Console.hh +++ b/include/gz/common/Console.hh @@ -46,8 +46,7 @@ namespace gz /// initialized or false otherwise. public: LogMessage(const char *_file, int _line, - spdlog::level::level_enum _logLevel, - bool _fileInitialize = false); + spdlog::level::level_enum _logLevel); /// \brief Destructor. public: ~LogMessage(); @@ -80,7 +79,7 @@ namespace gz /// \brief Output a message to a log file. #define gzlog gz::common::LogMessage( \ - __FILE__, __LINE__, spdlog::level::err, true).stream() + __FILE__, __LINE__, spdlog::level::err).stream() /// \brief Output a message. #define gzmsg gz::common::LogMessage( \ diff --git a/src/Console.cc b/src/Console.cc index 3b47c525..ca231d99 100644 --- a/src/Console.cc +++ b/src/Console.cc @@ -37,12 +37,12 @@ using namespace common; ///////////////////////////////////////////////// LogMessage::LogMessage(const char *_file, int _line, - spdlog::level::level_enum _logLevel, bool _fileInitialize) + spdlog::level::level_enum _logLevel) : severity(_logLevel), sourceLocation(_file, _line, "") { // Use default initialization if needed. - if (_fileInitialize && !Console::initialized) + if (!Console::initialized) Console::Init(".gz", "auto_default.log"); } @@ -108,8 +108,6 @@ bool Console::Init(const std::string &_directory, const std::string &_filename) logPath = joinPaths(logPath, _filename); Console::Root().SetLogDestination(logPath.c_str()); - Console::Root().RawLogger().log(spdlog::level::info, - "Setting log file output destination to {}", logPath.c_str()); Console::initialized = true; return true; diff --git a/src/Console_TEST.cc b/src/Console_TEST.cc index 922c9f5e..29efdd1d 100644 --- a/src/Console_TEST.cc +++ b/src/Console_TEST.cc @@ -203,8 +203,6 @@ TEST_F(Console_TEST, ColorWarnSlashN) gzwarn << logString << " _n__ " << i << '\n'; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -235,8 +233,6 @@ TEST_F(Console_TEST, ColorWarnStdEndl) gzwarn << logString << " endl " << i << std::endl; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -267,8 +263,6 @@ TEST_F(Console_TEST, ColorDbgSlashN) gzdbg << logString << " _n__ " << i << '\n'; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -299,8 +293,6 @@ TEST_F(Console_TEST, ColorDbgStdEndl) gzdbg << logString << " endl " << i << std::endl; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -331,8 +323,6 @@ TEST_F(Console_TEST, ColorMsgSlashN) gzmsg << logString << " _n__ " << i << '\n'; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -363,8 +353,6 @@ TEST_F(Console_TEST, ColorMsgStdEndl) gzmsg << logString << " endl " << i << std::endl; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -395,8 +383,6 @@ TEST_F(Console_TEST, ColorErrSlashN) gzerr << logString << " _n__ " << i << '\n'; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -427,8 +413,6 @@ TEST_F(Console_TEST, ColorErrStdEndl) gzerr << logString << " endl " << i << std::endl; } - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -456,8 +440,6 @@ TEST_F(Console_TEST, ColorMsg) gzmsg << logString << std::endl; - common::Console::Root().RawLogger().flush(); - std::string logContent = GetLogContent(logPath); EXPECT_TRUE(logContent.find(logString) != std::string::npos); @@ -527,8 +509,6 @@ TEST_F(Console_TEST, Prefix) gzmsg << "message" << std::endl; gzdbg << "debug" << std::endl; - common::Console::Root().RawLogger().flush(); - // Get the logged content std::string logContent = GetLogContent(logPath); From a1488d589d0a4d3b0d374f6d59e93cecbc6e3575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Thu, 29 Aug 2024 01:12:39 +0200 Subject: [PATCH 2/2] Remove doxygen parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- include/gz/common/Console.hh | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/gz/common/Console.hh b/include/gz/common/Console.hh index e99333a4..a188de20 100644 --- a/include/gz/common/Console.hh +++ b/include/gz/common/Console.hh @@ -42,8 +42,6 @@ namespace gz /// \param[in] _file Filename. /// \param[in] _line Line number. /// \param[in] _logLevel Log level. - /// \param[in] _fileInitialize True if the file logger needs to be - /// initialized or false otherwise. public: LogMessage(const char *_file, int _line, spdlog::level::level_enum _logLevel);