From ebbccf3af8a35719058932699ae92815495ab7e9 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Tue, 24 Sep 2024 12:06:41 +0200 Subject: [PATCH] Adapt code to new LogFilter struct Signed-off-by: Lucia Echevarria --- .../ddspipe_core/configuration/CommandlineArgs.hpp | 1 + .../src/cpp/configuration/CommandlineArgs.cpp | 6 +++--- .../logging/dds_consumer/DdsLogConsumerTest.cpp | 12 ++++++------ .../logging/std_consumer/StdLogConsumerTest.cpp | 12 ++++++------ .../status/logging/LogMonitorStatusTest.cpp | 2 +- .../topics/logging/LogMonitorTopicsTest.cpp | 2 +- .../log_configuration/YamlReaderLogConfiguration.cpp | 12 ++++++------ 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp b/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp index 721e6c3b..f9e12bfd 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include #include diff --git a/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp b/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp index c936f38f..2f9bb186 100644 --- a/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp +++ b/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp @@ -28,9 +28,9 @@ namespace core { CommandlineArgs::CommandlineArgs() { - log_filter[utils::VerbosityKind::Info].set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); - log_filter[utils::VerbosityKind::Warning].set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); - log_filter[utils::VerbosityKind::Error].set_value("", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.info.set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.warning.set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.error.set_value("", utils::FuzzyLevelValues::fuzzy_level_default); } bool CommandlineArgs::is_valid( diff --git a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp index 86c794a4..58bd506e 100644 --- a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp @@ -111,9 +111,9 @@ TEST_F(DdsLogConsumerTest, publish_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); @@ -205,9 +205,9 @@ TEST_F(DdsLogConsumerTest, dont_publish_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); diff --git a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp index 2f37df93..900cce0f 100644 --- a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp @@ -42,9 +42,9 @@ TEST(StdLogConsumerTest, print_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); @@ -102,9 +102,9 @@ TEST(StdLogConsumerTest, dont_print_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); diff --git a/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp b/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp index 2cf9df6b..01688dc9 100644 --- a/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp @@ -43,7 +43,7 @@ class LogMonitorStatusTest : public testing::Test utils::BaseLogConfiguration log_conf; log_conf.verbosity = utils::VerbosityKind::Info; - log_conf.filter[utils::VerbosityKind::Info].set_value("MONITOR_DATA"); + log_conf.filter.info.set_value("MONITOR_DATA"); utils::Log::SetVerbosity(log_conf.verbosity); diff --git a/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp b/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp index e05d8d7e..c94a88d1 100644 --- a/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp @@ -45,7 +45,7 @@ class LogMonitorTopicsTest : public testing::Test utils::BaseLogConfiguration log_conf; log_conf.verbosity = utils::VerbosityKind::Info; - log_conf.filter[utils::VerbosityKind::Info].set_value("MONITOR_DATA"); + log_conf.filter.info.set_value("MONITOR_DATA"); utils::Log::SetVerbosity(log_conf.verbosity); diff --git a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp index ce172c5f..7932fef6 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp +++ b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp @@ -62,9 +62,9 @@ TEST(YamlReaderLogConfiguration, parse_correct_LogConfiguration_yaml) // Verify that the verbosity and filters are correct ASSERT_EQ(conf.verbosity.get_value(), utils::VerbosityKind::Info); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Error).get_value(), "DDSPIPE"); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Warning).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Info).get_value(), "DEBUG"); + ASSERT_EQ(conf.filter.error.get_value(), "DDSPIPE"); + ASSERT_EQ(conf.filter.warning.get_value(), ""); + ASSERT_EQ(conf.filter.info.get_value(), "DEBUG"); } /** @@ -93,9 +93,9 @@ TEST(YamlReaderLogConfiguration, parse_correct_LogConfiguration_yaml_and_default ASSERT_TRUE(conf.is_valid(error_msg)); ASSERT_EQ(conf.verbosity.get_value(), utils::VerbosityKind::Warning); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Error).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Warning).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Info).get_value(), "DEBUG"); + ASSERT_EQ(conf.filter.error.get_value(), ""); + ASSERT_EQ(conf.filter.warning.get_value(), ""); + ASSERT_EQ(conf.filter.info.get_value(), "DEBUG"); } /**