Warn unrecognized sections in the config file

In the config file, sections are specified by square bracket pair "[]"$,
or included in the option name itself which separated by a period"(.)".

Typicaly, [testnet] is not a correct section name and specified options
in that section are ignored but user cannot recognize what is happen.

So, add some log/stderr-warning messages if unrecognized section names
are present in the config file after checking section only args.
This commit is contained in:
Akio Nakamura
2018-11-12 11:06:36 +09:00
parent 1b99d153d0
commit 3fb09b9889
4 changed files with 56 additions and 9 deletions

View File

@@ -149,6 +149,7 @@ protected:
std::string m_network GUARDED_BY(cs_args);
std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
std::set<std::string> m_config_sections GUARDED_BY(cs_args);
bool ReadConfigStream(std::istream& stream, std::string& error, bool ignore_invalid_keys = false);
@@ -169,7 +170,12 @@ public:
* on the command line or in a network-specific section in the
* config file.
*/
void WarnForSectionOnlyArgs();
const std::set<std::string> GetUnsuitableSectionOnlyArgs() const;
/**
* Log warnings for unrecognized section names in the config file.
*/
const std::set<std::string> GetUnrecognizedSections() const;
/**
* Return a vector of strings of the given argument