Skip to content

Commit

Permalink
Fix severity level of gzlog (#635)
Browse files Browse the repository at this point in the history
The severity level of `gzlog` was incorrectly set to `err`. Changing this to `trace` solves two problems:
1. The log message is now a lot less alarming 
2. When running `gz sim -v4`, this message is not shown on the console. It will only be logged to file. It does show up on the console if you run with `-v5`. 
 
The second point is technically a behavior change since in Harmonic, regardless of the verbosity level, `gzlog` would never show up on the console. However, duplicating that behavior with the new Console implementation proved to be very complicated. So, I propose we change the meaning of `gzlog` to be equivalent to `gztrace`.

Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored Sep 6, 2024
1 parent bbb3183 commit 0a4a80f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions graphics/src/ColladaLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ TEST_F(ColladaLoader, LoadZeroCount)
common::testing::TestFile("data", "zero_count.dae"));
ASSERT_TRUE(mesh);
#ifndef _WIN32
common::Console::Root().RawLogger().flush();
std::string log = LogContent();

// Expect no errors about missing values
Expand Down
2 changes: 1 addition & 1 deletion include/gz/common/Console.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace gz

/// \brief Output a message to a log file.
#define gzlog gz::common::LogMessage( \
__FILE__, __LINE__, spdlog::level::err).stream()
__FILE__, __LINE__, spdlog::level::trace).stream()

/// \brief Output a message.
#define gzmsg gz::common::LogMessage( \
Expand Down
4 changes: 4 additions & 0 deletions src/Console_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ TEST_F(Console_TEST, NoInitAndLog)
// Get the absolute log file path
std::string logPath = ".gz/auto_default.log";

common::Console::Root().RawLogger().flush();
// Expect to find the string in the log file
EXPECT_TRUE(GetLogContent(logPath).find(logString) != std::string::npos);

Expand Down Expand Up @@ -118,6 +119,7 @@ TEST_F(Console_TEST, InitAndLog)
// Get the absolute log file path
std::string logPath = common::joinPaths(path, "test.log");

common::Console::Root().RawLogger().flush();
// Expect to find the string in the log file
EXPECT_TRUE(GetLogContent(logPath).find(logString) != std::string::npos);

Expand Down Expand Up @@ -149,6 +151,7 @@ TEST_F(Console_TEST, LogSlashN)
gzlog << logString << " _n__ " << i << '\n';
}

common::Console::Root().RawLogger().flush();
std::string logContent = GetLogContent(logPath);

for (int i = 0; i < g_messageRepeat; ++i)
Expand Down Expand Up @@ -179,6 +182,7 @@ TEST_F(Console_TEST, LogStdEndl)
gzlog << logString << " endl " << i << std::endl;
}

common::Console::Root().RawLogger().flush();
std::string logContent = GetLogContent(logPath);

for (int i = 0; i < g_messageRepeat; ++i)
Expand Down

0 comments on commit 0a4a80f

Please sign in to comment.