Skip to content

Commit

Permalink
Merge pull request #651 from gazebosim/Crola1702/6_to_main-21_11_2024
Browse files Browse the repository at this point in the history
6 ➡️ main
  • Loading branch information
Crola1702 authored Nov 21, 2024
2 parents 8f3bed7 + 5a477d4 commit 7cbbe44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
39 changes: 20 additions & 19 deletions examples/console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,39 @@

int main(int argc, char **argv)
{
// Default verbosity is 3 (critical, error, warn and info messages show).
gztrace << "This is a trace message";
gzdbg << "This is a debug message";
gzmsg << "This is an informational message";
gzwarn << "This is a warning";
gzerr << "This is an error";
gzcrit << "This is a critical error";
// Default verbosity is level 1 (err).
gztrace << "This is a trace message" << std::endl;
gzdbg << "This is a debug message" << std::endl;
gzmsg << "This is an informational message" << std::endl;
gzwarn << "This is a warning" << std::endl;
gzerr << "This is an error" << std::endl;
gzcrit << "This is a critical error" << std::endl;

// Change verbosity to level 5, all messages show.
// Change verbosity to level 5 (trace), all messages show.
gz::common::Console::SetVerbosity(5);
gz::common::Console::SetPrefix("My prefix. ");
gztrace << "This is a trace message";
gzdbg << "This is a debug message";
gzmsg << "This is an informational message";
gzwarn << "This is a warning";
gzerr << "This is an error";
gzcrit << "This is a critical error";
gztrace << "This is a trace message" << std::endl;
gzdbg << "This is a debug message" << std::endl;
gzmsg << "This is an informational message" << std::endl;
gzwarn << "This is a warning" << std::endl;
gzerr << "This is an error" << std::endl;
gzcrit << "This is a critical error" << std::endl;

std::filesystem::path logDir = std::filesystem::temp_directory_path();
std::filesystem::path logFile = "my_log.txt";

gz::common::Console c("gz_tmp");
c.SetLogDestination(logDir / "tmp2" / logFile);
auto logger = c.RawLogger();
logger.log(spdlog::level::err, "Hello");
logger.log(spdlog::level::err, "Hello\n");

gz::common::Console::Init(logDir / "tmp3", logFile);
gzerr << "Error 1";
gzerr << "Error 2";
gzerr << "Directory: " << gz::common::Console::Directory();
gzerr << "Error 1" << std::endl;
gzerr << "Error 2" << std::endl;
gzerr << "Directory: " << gz::common::Console::Directory() << std::endl;
gz::common::Console::Close();
gzerr << "Error 3";
// We shouldn't see this line in the log.
gzerr << "Error 3" << std::endl;

return 0;
}
3 changes: 2 additions & 1 deletion graphics/src/SVGLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@

#include "tinyxml2.h"

#include "gz/math/Angle.hh"

#include "gz/common/Console.hh"
#include "gz/common/Util.hh"

#include "gz/common/SVGLoader.hh"

using namespace gz;
Expand Down

0 comments on commit 7cbbe44

Please sign in to comment.