aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLarry Ruane <larryruane@gmail.com>2020-01-20 08:32:42 -0700
committerLarry Ruane <larryruane@gmail.com>2020-01-29 15:44:00 -0700
commitb951b0973cfd4e0db4607a00d434a04afb0d6199 (patch)
tree2acf7234057a1b41be604373c885ac431ae9a9f2 /src/util
parentaabec94541e23a67a9f30dc2c80dab3383a01737 (diff)
downloadbitcoin-b951b0973cfd4e0db4607a00d434a04afb0d6199.tar.xz
on startup, write config options to debug.log
Diffstat (limited to 'src/util')
-rw-r--r--src/util/system.cpp26
-rw-r--r--src/util/system.h15
2 files changed, 41 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 588ddc1fcf..ff3967c577 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -864,6 +864,32 @@ std::vector<util::SettingsValue> ArgsManager::GetSettingsList(const std::string&
return util::GetSettingsList(m_settings, m_network, SettingName(arg), !UseDefaultSection(arg));
}
+void ArgsManager::logArgsPrefix(
+ const std::string& prefix,
+ const std::string& section,
+ const std::map<std::string, std::vector<util::SettingsValue>>& args) const
+{
+ std::string section_str = section.empty() ? "" : "[" + section + "] ";
+ for (const auto& arg : args) {
+ for (const auto& value : arg.second) {
+ Optional<unsigned int> flags = GetArgFlags('-' + arg.first);
+ if (flags) {
+ std::string value_str = (*flags & SENSITIVE) ? "****" : value.write();
+ LogPrintf("%s %s%s=%s\n", prefix, section_str, arg.first, value_str);
+ }
+ }
+ }
+}
+
+void ArgsManager::LogArgs() const
+{
+ LOCK(cs_args);
+ for (const auto& section : m_settings.ro_config) {
+ logArgsPrefix("Config file arg:", section.first, section.second);
+ }
+ logArgsPrefix("Command-line arg:", "", m_settings.command_line_options);
+}
+
bool RenameOver(fs::path src, fs::path dest)
{
#ifdef WIN32
diff --git a/src/util/system.h b/src/util/system.h
index 473019bbed..bb69181de9 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -145,6 +145,8 @@ public:
* between mainnet and regtest/testnet won't cause problems due to these
* parameters by accident. */
NETWORK_ONLY = 0x200,
+ // This argument's value is sensitive (such as a password).
+ SENSITIVE = 0x400,
};
protected:
@@ -318,6 +320,19 @@ public:
* Return nullopt for unknown arg.
*/
Optional<unsigned int> GetArgFlags(const std::string& name) const;
+
+ /**
+ * Log the config file options and the command line arguments,
+ * useful for troubleshooting.
+ */
+ void LogArgs() const;
+
+private:
+ // Helper function for LogArgs().
+ void logArgsPrefix(
+ const std::string& prefix,
+ const std::string& section,
+ const std::map<std::string, std::vector<util::SettingsValue>>& args) const;
};
extern ArgsManager gArgs;