Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
LuciaEchevarria99 marked this conversation as resolved.
Comment thread
LuciaEchevarria99 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include <set>

#include <cpp_utils/Formatter.hpp>
#include <cpp_utils/logging/LogConfiguration.hpp>

#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/DdsPipeLogConfiguration.hpp>
#include <ddspipe_core/configuration/IConfiguration.hpp>
#include <ddspipe_core/types/dds/TopicQoS.hpp>

Expand Down Expand Up @@ -72,8 +72,8 @@ struct SpecsConfiguration : public ddspipe::core::IConfiguration
//! The type of the entities whose discovery triggers the discovery callbacks.
ddspipe::core::DiscoveryTrigger discovery_trigger = ddspipe::core::DiscoveryTrigger::READER;

//! Configuration of the CustomStdLogConsumer.
utils::LogConfiguration log_configuration;
//! Configuration of the DDS Pipe's Log consumers.
ddspipe::core::DdsPipeLogConfiguration log_configuration;
};

} /* namespace core */
Expand Down
3 changes: 2 additions & 1 deletion ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void YamlReader::fill(
// Get optional Log Configuration
if (YamlReader::is_tag_present(yml, LOG_CONFIGURATION_TAG))
{
object.log_configuration = YamlReader::get<utils::LogConfiguration>(yml, LOG_CONFIGURATION_TAG, version);
object.log_configuration = YamlReader::get<ddspipe::core::DdsPipeLogConfiguration>(yml, LOG_CONFIGURATION_TAG,
version);
}
}

Expand Down
57 changes: 57 additions & 0 deletions docs/rst/user_manual/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,55 @@ By default, the filter allows all errors to be displayed, while selectively perm

For the logs to function properly, the ``-DLOG_INFO=ON`` compilation flag is required.

The |ddsrouter| prints the logs by default (warnings and errors in the standard error and infos in the standard output).
The |ddsrouter|, however, can also publish the logs in a DDS topic.
To publish the logs, under the tag ``publish``, set ``enable: true`` and set a ``domain`` and a ``topic-name``.
The type of the logs published is defined as follows:

**LogEntry.idl**

.. code-block:: idl

const long UNDEFINED = 0x10000000;
const long SAMPLE_LOST = 0x10000001;
const long TOPIC_MISMATCH_TYPE = 0x10000002;
const long TOPIC_MISMATCH_QOS = 0x10000003;

enum Kind {
Info,
Warning,
Error
};

struct LogEntry {
@key long event;
Kind kind;
string category;
string message;
string timestamp;
};

.. note::

The type of the logs can be published by setting ``publish-type: true``.

**Example of usage**

.. code-block:: yaml

logging:
verbosity: info
filter:
error: "DDSPIPE|DDSROUTER"
warning: "DDSPIPE|DDSROUTER"
info: "DDSROUTER"
publish:
enable: true
domain: 84
topic-name: "DdsRouterLogs"
publish-type: false
stdout: true

Participant Configuration
=========================

Expand Down Expand Up @@ -879,17 +928,25 @@ A complete example of all the configurations described on this page can be found
threads: 10
remove-unused-entities: false
discovery-trigger: reader

qos:
history-depth: 1000
max-tx-rate: 0
max-rx-rate: 20
downsampling: 3

logging:
verbosity: info
filter:
error: "DDSPIPE|DDSROUTER"
warning: "DDSPIPE|DDSROUTER"
info: "DDSROUTER"
publish:
enable: true
domain: 84
topic-name: "DdsRouterLogs"
publish-type: false
stdout: true

# XML configurations to load
xml:
Expand Down
31 changes: 23 additions & 8 deletions tools/ddsrouter_tool/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#include <cpp_utils/event/SignalEventHandler.hpp>
#include <cpp_utils/exception/ConfigurationException.hpp>
#include <cpp_utils/exception/InitializationException.hpp>
#include <cpp_utils/logging/CustomStdLogConsumer.hpp>
#include <cpp_utils/logging/LogConfiguration.hpp>
#include <cpp_utils/logging/StdLogConsumer.hpp>
#include <cpp_utils/ReturnCode.hpp>
#include <cpp_utils/time/time_utils.hpp>
#include <cpp_utils/utils.hpp>

#include <ddspipe_core/logging/DdsLogConsumer.hpp>

#include <ddspipe_participants/xml/XmlHandler.hpp>

#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
Expand Down Expand Up @@ -90,7 +91,6 @@ int main(

logUser(DDSROUTER_EXECUTION, "Starting DDS Router Tool execution.");


// Encapsulating execution in block to erase all memory correctly before closing process
try
{
Expand Down Expand Up @@ -126,15 +126,27 @@ int main(

// Debug
{
const auto log_configuration = router_configuration.ddspipe_configuration.log_configuration;

// Remove every consumer
eprosima::utils::Log::ClearConsumers();

// Activate log with verbosity, as this will avoid running log thread with not desired kind
eprosima::utils::Log::SetVerbosity(router_configuration.ddspipe_configuration.log_configuration.verbosity);

eprosima::utils::LogConfiguration log_config = router_configuration.ddspipe_configuration.log_configuration;
eprosima::utils::Log::RegisterConsumer(
std::make_unique<eprosima::utils::CustomStdLogConsumer>(&log_config));
eprosima::utils::Log::SetVerbosity(log_configuration.verbosity);

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

// DDS Log Consumer
if (log_configuration.publish.enable)
{
eprosima::utils::Log::RegisterConsumer(
std::make_unique<eprosima::ddspipe::core::DdsLogConsumer>(&log_configuration));
}

// NOTE:
// It will not filter any log, so Fast DDS logs will be visible unless Fast DDS is compiled
Expand Down Expand Up @@ -267,5 +279,8 @@ int main(
// Force print every log before closing
eprosima::utils::Log::Flush();

// Delete the consumers before closing
eprosima::utils::Log::ClearConsumers();

return static_cast<int>(ui::ProcessReturnCode::success);
}