diff --git a/include/gz/common/Console.hh b/include/gz/common/Console.hh index 48aa5523..a188de20 100644 --- a/include/gz/common/Console.hh +++ b/include/gz/common/Console.hh @@ -42,12 +42,9 @@ 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, - bool _fileInitialize = false); + spdlog::level::level_enum _logLevel); /// \brief Destructor. public: ~LogMessage(); @@ -80,7 +77,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 eac69666..97d65c32 100644 --- a/src/Console_TEST.cc +++ b/src/Console_TEST.cc @@ -209,8 +209,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) @@ -241,8 +239,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) @@ -273,8 +269,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) @@ -305,8 +299,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) @@ -337,8 +329,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) @@ -369,8 +359,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) @@ -401,8 +389,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) @@ -433,8 +419,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) @@ -462,8 +446,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); @@ -533,8 +515,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);