From 768cdbd9d4e2f091efd3ba2eac4bdc2ea83890f5 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 23 Oct 2024 10:55:15 -0400 Subject: [PATCH] Improve parameter summary --- .../JANA/Services/JParameterManager.cc | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libraries/JANA/Services/JParameterManager.cc b/src/libraries/JANA/Services/JParameterManager.cc index 64f14e758..7b8014af9 100644 --- a/src/libraries/JANA/Services/JParameterManager.cc +++ b/src/libraries/JANA/Services/JParameterManager.cc @@ -139,10 +139,10 @@ void JParameterManager::PrintParameters(int verbosity, int strictness) { for (auto& pair : m_parameters) { auto param = pair.second; - if (param->IsDeprecated() && (param->IsDefault())) continue; + if (param->IsDeprecated() && (param->IsDefault())) continue; // Always hide deprecated parameters that are NOT in use - if ((verbosity == 1) && (param->IsDefault())) continue; + if ((verbosity == 1) && (param->IsDefault())) continue; // At verbosity level 1, hide all default-valued parameters if ((verbosity == 2) && (param->IsDefault()) && (param->IsAdvanced())) continue; @@ -157,48 +157,48 @@ void JParameterManager::PrintParameters(int verbosity, int strictness) { return; } - std::ostringstream ss; + LOG_WARN(m_logger) << "Configuration Parameters" << LOG_END; for (JParameter* p: params_to_print) { - ss << std::endl; - ss << " - key: \"" << p->GetKey() << "\"" << std::endl; + LOG_WARN(m_logger) << LOG_END; + LOG_WARN(m_logger) << " - key: " << p->GetKey() << LOG_END; if (!p->IsDefault()) { - ss << " value: \"" << p->GetValue() << "\"" << std::endl; + LOG_WARN(m_logger) << " value: " << p->GetValue() << LOG_END; + } + if (p->HasDefault()) { + LOG_WARN(m_logger) << " default: " << p->GetDefault() << LOG_END; } - ss << " default: \"" << p->GetDefault() << "\"" << std::endl; if (!p->GetDescription().empty()) { - ss << " description: "; std::istringstream iss(p->GetDescription()); std::string line; bool is_first_line = true; while (std::getline(iss, line)) { - if (!is_first_line) { - ss << std::endl << " " << line; + if (is_first_line) { + LOG_INFO(m_logger) << " description: " << line << LOG_END; } else { - ss << line; + LOG_INFO(m_logger) << " " << line << LOG_END; } is_first_line = false; } - ss << std::endl; } if (p->IsConflicted()) { - ss << " warning: Conflicting defaults" << std::endl; + LOG_WARN(m_logger) << " warning: Conflicting defaults" << LOG_END; } if (p->IsDeprecated()) { - ss << " warning: Deprecated" << std::endl; + LOG_WARN(m_logger) << " warning: Deprecated" << LOG_END; // If deprecated, it no longer matters whether it is advanced or not. If unused, won't show up here anyway. } if (!p->IsUsed()) { // Can't be both deprecated and unused, since JANA only finds out that it is deprecated by trying to use it // Can't be both advanced and unused, since JANA only finds out that it is advanced by trying to use it - ss << " warning: Unused" << std::endl; + LOG_WARN(m_logger) << " warning: Unused" << LOG_END; } if (p->IsAdvanced()) { - ss << " warning: Advanced" << std::endl; + LOG_WARN(m_logger) << " warning: Advanced" << LOG_END; } } - LOG_WARN(m_logger) << "Configuration Parameters\n" << ss.str() << LOG_END; + LOG_WARN(m_logger) << LOG_END; // Now that we've printed the table, we can throw an exception if we are being super strict if (strictness_violation && strictness > 1) {