30
30
#include < cpp_utils/types/Fuzzy.hpp>
31
31
#include < cpp_utils/utils.hpp>
32
32
33
+ #include < ddspipe_core/configuration/DdsPipeLogConfiguration.hpp>
33
34
#include < ddspipe_core/core/DdsPipe.hpp>
34
35
#include < ddspipe_core/dynamic/ParticipantsDatabase.hpp>
35
36
#include < ddspipe_core/dynamic/DiscoveryDatabase.hpp>
49
50
50
51
51
52
int exit (const eprosima::spy::ProcessReturnCode& code);
53
+ void register_log_consumers (const eprosima::ddspipe::core::DdsPipeLogConfiguration& configuration);
52
54
53
55
54
56
int main (
@@ -99,6 +101,12 @@ int main(
99
101
// Encapsulating execution in block to erase all memory correctly before closing process
100
102
try
101
103
{
104
+ // Register the LogConsumers to log the YAML configuration errors
105
+ eprosima::ddspipe::core::DdsPipeLogConfiguration log_configuration;
106
+ log_configuration.set (eprosima::utils::VerbosityKind::Warning);
107
+
108
+ register_log_consumers (log_configuration);
109
+
102
110
// ///
103
111
// Fast DDS Spy Initialization
104
112
@@ -113,37 +121,8 @@ int main(
113
121
eprosima::spy::yaml::Configuration configuration = eprosima::spy::yaml::Configuration (
114
122
commandline_args.file_path , &commandline_args);
115
123
116
- // Debug
117
- {
118
- const auto log_configuration = configuration.ddspipe_configuration .log_configuration ;
119
-
120
- // Remove every consumer
121
- eprosima::utils::Log::ClearConsumers ();
122
-
123
- // Activate log with verbosity, as this will avoid running log thread with not desired kind
124
- eprosima::utils::Log::SetVerbosity (configuration.ddspipe_configuration .log_configuration .verbosity );
125
-
126
- // Stdout Log Consumer
127
- if (log_configuration.stdout_enable )
128
- {
129
- eprosima::utils::Log::RegisterConsumer (
130
- std::make_unique<eprosima::utils::StdLogConsumer>(&log_configuration));
131
- }
132
-
133
- // DDS Log Consumer
134
- if (log_configuration.publish .enable )
135
- {
136
- eprosima::utils::Log::RegisterConsumer (
137
- std::make_unique<eprosima::ddspipe::core::DdsLogConsumer>(&log_configuration));
138
- }
139
-
140
- // NOTE:
141
- // It will not filter any log, so Fast DDS logs will be visible unless Fast DDS is compiled
142
- // in non debug or with LOG_NO_INFO=ON.
143
- // This is the easiest way to allow to see Warnings and Errors from Fast DDS.
144
- // Change it when Log Module is independent and with more extensive API.
145
- // eprosima::utils::Log::SetCategoryFilter(std::regex("(ddspipe|FASTDDSSPY)"));
146
- }
124
+ register_log_consumers (configuration.ddspipe_configuration .log_configuration );
125
+
147
126
// Create the Spy
148
127
eprosima::spy::Controller spy (configuration);
149
128
@@ -260,3 +239,33 @@ int exit(const eprosima::spy::ProcessReturnCode& code)
260
239
261
240
return static_cast <int >(code);
262
241
}
242
+
243
+ void register_log_consumers (const eprosima::ddspipe::core::DdsPipeLogConfiguration& configuration)
244
+ {
245
+ // Remove every consumer
246
+ eprosima::utils::Log::ClearConsumers ();
247
+
248
+ // Activate log with verbosity, as this will avoid running log thread with not desired kind
249
+ eprosima::utils::Log::SetVerbosity (configuration.verbosity );
250
+
251
+ // Stdout Log Consumer
252
+ if (configuration.stdout_enable )
253
+ {
254
+ eprosima::utils::Log::RegisterConsumer (
255
+ std::make_unique<eprosima::utils::StdLogConsumer>(&configuration));
256
+ }
257
+
258
+ // DDS Log Consumer
259
+ if (configuration.publish .enable )
260
+ {
261
+ eprosima::utils::Log::RegisterConsumer (
262
+ std::make_unique<eprosima::ddspipe::core::DdsLogConsumer>(&configuration));
263
+ }
264
+
265
+ // NOTE:
266
+ // It will not filter any log, so Fast DDS logs will be visible unless Fast DDS is compiled
267
+ // in non debug or with LOG_NO_INFO=ON.
268
+ // This is the easiest way to allow to see Warnings and Errors from Fast DDS.
269
+ // Change it when Log Module is independent and with more extensive API.
270
+ // utils::Log::SetCategoryFilter(std::regex("(FASTDDSSPY)"));
271
+ }
0 commit comments