Skip to content

Commit

Permalink
Improve parameter summary
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Oct 23, 2024
1 parent 7bf1db2 commit 768cdbd
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/libraries/JANA/Services/JParameterManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 768cdbd

Please sign in to comment.