From 0d514c67a19123194303eae366880fbe5bfccfa0 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Jul 2023 11:55:42 -0500 Subject: [PATCH 1/3] GH-1279 Print non-default options --- libraries/appbase | 2 +- programs/nodeos/main.cpp | 48 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/libraries/appbase b/libraries/appbase index 54cc7fb4f9..0f959acba5 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 54cc7fb4f9a3dbbe2c71bdf23f9342c9c01b9673 +Subproject commit 0f959acba5664e0271d3ba6cf3dc1d99abe2663f diff --git a/programs/nodeos/main.cpp b/programs/nodeos/main.cpp index 2deda685f6..dc9552e048 100644 --- a/programs/nodeos/main.cpp +++ b/programs/nodeos/main.cpp @@ -11,10 +11,16 @@ #include #include #include +#include #include #include +#include +#include +#include +#include + #include "config.hpp" using namespace appbase; @@ -22,6 +28,39 @@ using namespace eosio; namespace detail { +void log_non_default_options(const std::vector>& options) { + string result; + for (const auto& op : options) { + bool mask = false; + if (op.string_key == "signature-provider" + || op.string_key == "peer-private-key" + || op.string_key == "p2p-auto-bp-peer") { + mask = true; + } + std::string v; + for (auto i = op.value.cbegin(), b = op.value.cbegin(), e = op.value.cend(); i != e; ++i) { + if (i != b) + v += ", "; + if (mask) + v += "***"; + else + v += *i; + } + + if (!result.empty()) + result += ", "; + + if (v.empty()) { + result += op.string_key; + } else { + result += op.string_key; + result += " = "; + result += v; + } + } + ilog("Non-default options: ${v}", ("v", result)); +} + fc::logging_config& add_deep_mind_logger(fc::logging_config& config) { config.appenders.push_back( fc::appender_config( "deep-mind", "dmlog" ) @@ -109,6 +148,12 @@ int main(int argc, char** argv) { try { appbase::scoped_app app; + fc::scoped_exit> on_exit = [&]() { + ilog("${name} version ${ver} ${fv}", + ("name", nodeos::config::node_executable_name)("ver", app->version_string()) + ("fv", app->version_string() == app->full_version_string() ? "" : app->full_version_string()) ); + ::detail::log_non_default_options(app->get_parsed_options()); + }; uint32_t short_hash = 0; fc::from_hex(eosio::version::version_hash(), (char*)&short_hash, sizeof(short_hash)); @@ -137,11 +182,12 @@ int main(int argc, char** argv) elog("resource_monitor_plugin failed to initialize"); return INITIALIZE_FAIL; } - ilog( "${name} version ${ver} ${fv}", + ilog("${name} version ${ver} ${fv}", ("name", nodeos::config::node_executable_name)("ver", app->version_string()) ("fv", app->version_string() == app->full_version_string() ? "" : app->full_version_string()) ); ilog("${name} using configuration file ${c}", ("name", nodeos::config::node_executable_name)("c", app->full_config_file_path().string())); ilog("${name} data directory is ${d}", ("name", nodeos::config::node_executable_name)("d", app->data_dir().string())); + ::detail::log_non_default_options(app->get_parsed_options()); app->startup(); app->set_thread_priority_max(); app->exec(); From 73e6abea618f27ce921a6b61f1d5a48d85daa175 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Jul 2023 18:00:12 -0500 Subject: [PATCH 2/3] GH-1279 Update appbase to main --- libraries/appbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/appbase b/libraries/appbase index 0f959acba5..2da170ea8c 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 0f959acba5664e0271d3ba6cf3dc1d99abe2663f +Subproject commit 2da170ea8c39442c7d1374c3403e80d60338b34d From 81a3a773983b9b42bb739b89e1cfda9a0ababd5d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Jul 2023 18:23:27 -0500 Subject: [PATCH 3/3] GH-1279 Use string literals --- programs/nodeos/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/programs/nodeos/main.cpp b/programs/nodeos/main.cpp index dc9552e048..6c99a2fdd4 100644 --- a/programs/nodeos/main.cpp +++ b/programs/nodeos/main.cpp @@ -29,12 +29,13 @@ using namespace eosio; namespace detail { void log_non_default_options(const std::vector>& options) { + using namespace std::string_literals; string result; for (const auto& op : options) { bool mask = false; - if (op.string_key == "signature-provider" - || op.string_key == "peer-private-key" - || op.string_key == "p2p-auto-bp-peer") { + if (op.string_key == "signature-provider"s + || op.string_key == "peer-private-key"s + || op.string_key == "p2p-auto-bp-peer"s) { mask = true; } std::string v;