Skip to content

Commit

Permalink
Merge branch 'main' into aditya/disable_GeoRef_console_prints
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapande-1995 authored May 17, 2022
2 parents 8bcc9d0 + d5f1c97 commit 600670b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ void FileLogger::Init(const std::string &_directory,
{
if (!env(IGN_HOMEDIR, logPath))
{
ignerr << "Missing HOME environment variable."
<< "No log file will be generated.";
// Use stderr here to prevent infinite recursion
// trying to get the log initialized
std::cerr << "Missing HOME environment variable."
<< "No log file will be generated." << std::endl;
return;
}
logPath = joinPaths(logPath, _directory);
Expand Down
11 changes: 11 additions & 0 deletions src/Console_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,14 @@ TEST_F(Console_TEST, LogDirectory)

EXPECT_EQ(logDir, absPath);
}

/////////////////////////////////////////////////
/// \brief Test Console::Init and Console::Log
/// This specifically tests with an unset HOME variable
TEST_F(Console_TEST, NoInitAndLogNoHome)
{
ignLogClose();
EXPECT_TRUE(ignition::common::unsetenv(IGN_HOMEDIR));
// This should not throw
ignlog << "this is a test" << std::endl;
}

0 comments on commit 600670b

Please sign in to comment.