Skip to content

Commit

Permalink
Merge pull request #10 from nobleo/silence/matching-loggers
Browse files Browse the repository at this point in the history
Stop flooding the terminal by default with all matches, switch to debug if desired
  • Loading branch information
MCFurry authored Jun 18, 2024
2 parents 901cb4c + 86bb786 commit 8327ead
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GenericAnalyzerBase : public Analyzer

has_initialized_ = true;

RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzerBase"),
"Initialized analyzer '%s' with path '%s' and breadcrumb '%s'.", nice_name_.c_str(),
path_.c_str(), breadcrumb_.c_str());
Expand Down
10 changes: 5 additions & 5 deletions diagnostic_aggregator/src/analyzer_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool AnalyzerGroup::init(
breadcrumb_.c_str(), n->get_namespace());
return false;
}
RCLCPP_INFO(
RCLCPP_DEBUG(
logger_, "Retrieved %zu parameter(s) for analyzer group with prefix '%s'.", parameters.size(),
breadcrumb_.c_str());

Expand Down Expand Up @@ -112,7 +112,7 @@ bool AnalyzerGroup::init(
}

if (!ns.empty() && !an_type.empty() && !an_path.empty()) {
RCLCPP_INFO(
RCLCPP_DEBUG(
logger_, "Group '%s', creating %s '%s' (breadcrumb: %s) ...", nice_name_.c_str(),
an_type.c_str(), an_path.c_str(), ns.c_str());

Expand Down Expand Up @@ -175,7 +175,7 @@ bool AnalyzerGroup::init(
init_ok = false;
RCLCPP_ERROR(logger_, "No analyzers initialized in AnalyzerGroup '%s'", n->get_namespace());
} else {
RCLCPP_INFO(
RCLCPP_DEBUG(
logger_, "Initialized analyzer group '%s' with path '%s' and breadcrumb '%s'.",
nice_name_.c_str(), path_.c_str(), breadcrumb_.c_str());
}
Expand All @@ -191,7 +191,7 @@ AnalyzerGroup::~AnalyzerGroup()

bool AnalyzerGroup::addAnalyzer(std::shared_ptr<Analyzer> & analyzer)
{
RCLCPP_INFO(
RCLCPP_DEBUG(
logger_, "Adding analyzer '%s' to group '%s'.", analyzer->getName().c_str(),
nice_name_.c_str());
analyzers_.push_back(analyzer);
Expand Down Expand Up @@ -238,7 +238,7 @@ bool AnalyzerGroup::match(const std::string & name)
match_name = mtch || match_name;
matched_[name].at(i) = mtch;
if (mtch) {
RCLCPP_INFO(
RCLCPP_DEBUG(
logger_, "Group '%s' has a match with my analyzer '%s'.", nice_name_.c_str(),
analyzers_[i]->getName().c_str());
}
Expand Down
10 changes: 5 additions & 5 deletions diagnostic_aggregator/src/generic_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool GenericAnalyzer::match(const string & name)
std::cmatch what;
for (unsigned int i = 0; i < regex_.size(); ++i) {
if (std::regex_match(name.c_str(), what, regex_[i])) {
RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzer"), "Analyzer '%s' matches '%s' with regex.",
nice_name_.c_str(), name.c_str());
return true;
Expand All @@ -201,7 +201,7 @@ bool GenericAnalyzer::match(const string & name)

for (unsigned int i = 0; i < expected_.size(); ++i) {
if (name == expected_[i]) {
RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzer"), "Analyzer '%s' matches '%s'.", nice_name_.c_str(),
name.c_str());
return true;
Expand All @@ -210,7 +210,7 @@ bool GenericAnalyzer::match(const string & name)

for (unsigned int i = 0; i < name_.size(); ++i) {
if (name == name_[i]) {
RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzer"), "Analyzer '%s' matches '%s'.", nice_name_.c_str(),
name.c_str());
return true;
Expand All @@ -219,7 +219,7 @@ bool GenericAnalyzer::match(const string & name)

for (unsigned int i = 0; i < startswith_.size(); ++i) {
if (name.find(startswith_[i]) == 0) {
RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzer"), "Analyzer '%s' matches '%s'.", nice_name_.c_str(),
name.c_str());
return true;
Expand All @@ -228,7 +228,7 @@ bool GenericAnalyzer::match(const string & name)

for (unsigned int i = 0; i < contains_.size(); ++i) {
if (name.find(contains_[i]) != string::npos) {
RCLCPP_INFO(
RCLCPP_DEBUG(
rclcpp::get_logger("GenericAnalyzer"), "Analyzer '%s' matches '%s'.", nice_name_.c_str(),
name.c_str());
return true;
Expand Down
8 changes: 6 additions & 2 deletions diagnostic_aggregator/test/add_analyzers.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def generate_test_description():
"@AGGREGATOR_NODE@",
"--ros-args",
"--params-file",
"@PARAMETER_FILE@"
"@PARAMETER_FILE@",
"--log-level",
"DEBUG"
],
name='aggregator_node',
emulate_tty=True,
Expand All @@ -34,7 +36,9 @@ def generate_test_description():
"@ADD_ANALYZER@",
"--ros-args",
"--params-file",
"@ADD_PARAMETER_FILE@"
"@ADD_PARAMETER_FILE@",
"--log-level",
"DEBUG"
],
name='add_analyzer',
emulate_tty=True,
Expand Down
4 changes: 3 additions & 1 deletion diagnostic_aggregator/test/create_analyzers.launch.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def generate_test_description():
"@AGGREGATOR_NODE@",
"--ros-args",
"--params-file",
"@PARAMETER_FILE@"
"@PARAMETER_FILE@",
"--log-level",
"DEBUG"
],
name='aggregator_node',
emulate_tty=True,
Expand Down

0 comments on commit 8327ead

Please sign in to comment.