Skip to content

Commit

Permalink
Adapt code to new LogFilter struct
Browse files Browse the repository at this point in the history
Signed-off-by: Lucia Echevarria <luciaechevarria@eprosima.com>
  • Loading branch information
LuciaEchevarria99 committed Sep 24, 2024
1 parent 101604b commit ebbccf3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <cpp_utils/logging/BaseLogConfiguration.hpp>
#include <cpp_utils/logging/LogFilter.hpp>
#include <cpp_utils/time/time_utils.hpp>
#include <cpp_utils/types/Fuzzy.hpp>
#include <cpp_utils/utils.hpp>
Expand Down
6 changes: 3 additions & 3 deletions ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down Expand Up @@ -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");
}

/**
Expand Down

0 comments on commit ebbccf3

Please sign in to comment.