Skip to content

Commit

Permalink
add logging settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Niemeyer committed Sep 10, 2024
1 parent b96fb2b commit 8cb3daa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
// geographic lib
#include <GeographicLib/LocalCartesian.hpp>

// logging
#include <boost/log/core.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/file.hpp>

namespace seerep_grpc_ros
{
class JsonPointDumper
Expand Down
16 changes: 14 additions & 2 deletions examples/cpp/seerep_ros_communication/src/jsonPointDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace seerep_grpc_ros
JsonPointDumper::JsonPointDumper(const std::string& filePath, const std::string& hdf5FilePath,
const std::string& classesMappingPath)
{
boost::log::add_common_attributes();
boost::log::register_simple_formatter_factory<boost::log::trivial::severity_level, char>("Severity");
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::error);

if (!std::filesystem::exists(filePath))
{
throw std::invalid_argument(filePath + " does not exist.");
Expand Down Expand Up @@ -266,8 +270,16 @@ std::string JsonPointDumper::translateNameToAgrovocConcept(std::string name)

if (parsingSuccessful)
{
concept = root.get("results", name).get("bindings", name)[0].get("c", name).get("value", name).asString();
name2Concept.emplace(name, concept);
try
{
concept = root.get("results", name).get("bindings", name)[0].get("c", name).get("value", name).asString();
name2Concept.emplace(name, concept);
}
catch (...)
{
std::cout << "unknown label: " << name << std::endl;
concept = "unknown";
}
}
}

Expand Down

0 comments on commit 8cb3daa

Please sign in to comment.