Skip to content

Commit

Permalink
Configure the publication of logs through YAML
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Feb 15, 2024
1 parent f74d89b commit ce133e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
28 changes: 19 additions & 9 deletions ddsrecorder/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include <ddsrecorder_yaml/recorder/CommandlineArgsRecorder.hpp>
#include <ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp>

#include <ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.h>
#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13)
#include <ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntry.h>
#else
#include <ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntry.h>
#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13)

#include "user_interface/arguments_configuration.hpp"
#include "user_interface/constants.hpp"
Expand Down Expand Up @@ -270,18 +274,24 @@ int main(
eprosima::utils::Log::SetVerbosity(configuration.ddspipe_configuration.log_configuration.verbosity);

// Stdout Log Consumer
eprosima::utils::Log::RegisterConsumer(
std::make_unique<eprosima::utils::CustomStdLogConsumer>(configuration.ddspipe_configuration.log_configuration));
if (configuration.ddspipe_configuration.log_configuration.stdout_enable)
{
eprosima::utils::Log::RegisterConsumer(
std::make_unique<eprosima::utils::CustomStdLogConsumer>(&configuration.ddspipe_configuration.log_configuration));
}

// DDS Log Consumer
auto consumer = std::make_unique<eprosima::ddspipe::core::DdsLogConsumer>(
configuration.ddspipe_configuration.log_configuration);
if (configuration.ddspipe_configuration.log_configuration.publish.enable)
{
auto consumer = std::make_unique<eprosima::ddspipe::core::DdsLogConsumer>(
configuration.ddspipe_configuration.log_configuration);

// Add DdsRecorder specific events
consumer->add_event("FAIL_MCAP_CREATION", FAIL_MCAP_CREATION);
consumer->add_event("FAIL_MCAP_WRITE", FAIL_MCAP_WRITE);
// Add DdsRecorder specific events
consumer->add_event("FAIL_MCAP_CREATION", FAIL_MCAP_CREATION);
consumer->add_event("FAIL_MCAP_WRITE", FAIL_MCAP_WRITE);

eprosima::utils::Log::RegisterConsumer(std::move(consumer));
eprosima::utils::Log::RegisterConsumer(std::move(consumer));
}
}

logUser(DDSRECORDER_EXECUTION, "DDS Recorder running.");
Expand Down
4 changes: 2 additions & 2 deletions ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <cpp_utils/utils.hpp>

#include <ddspipe_core/configuration/DdsPipeLogConfiguration.hpp>
#include <ddspipe_core/types/dynamic_types/types.hpp>
#include <ddspipe_core/types/topic/filter/ManualTopic.hpp>
#include <ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp>
Expand All @@ -29,7 +30,6 @@
#include <ddspipe_yaml/YamlManager.hpp>

#include <ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp>

#include <ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp>

namespace eprosima {
Expand Down Expand Up @@ -331,7 +331,7 @@ void RecorderConfiguration::load_specs_configuration_(
// Get optional Log Configuration
if (YamlReader::is_tag_present(yml, LOG_CONFIGURATION_TAG))
{
ddspipe_configuration.log_configuration = YamlReader::get<utils::LogConfiguration>(yml, LOG_CONFIGURATION_TAG, version);
ddspipe_configuration.log_configuration = YamlReader::get<DdsPipeLogConfiguration>(yml, LOG_CONFIGURATION_TAG, version);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <cpp_utils/utils.hpp>

#include <ddspipe_core/configuration/DdsPipeLogConfiguration.hpp>
#include <ddspipe_core/types/dynamic_types/types.hpp>
#include <ddspipe_core/types/topic/filter/ManualTopic.hpp>
#include <ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp>
Expand All @@ -30,7 +31,6 @@
#include <ddspipe_yaml/YamlManager.hpp>

#include <ddsrecorder_yaml/replayer/yaml_configuration_tags.hpp>

#include <ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp>

namespace eprosima {
Expand Down Expand Up @@ -231,7 +231,7 @@ void ReplayerConfiguration::load_specs_configuration_(
// Get optional Log Configuration
if (YamlReader::is_tag_present(yml, LOG_CONFIGURATION_TAG))
{
ddspipe_configuration.log_configuration = YamlReader::get<utils::LogConfiguration>(yml, LOG_CONFIGURATION_TAG, version);
ddspipe_configuration.log_configuration = YamlReader::get<DdsPipeLogConfiguration>(yml, LOG_CONFIGURATION_TAG, version);
}
}

Expand Down

0 comments on commit ce133e8

Please sign in to comment.