New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config options split into two files #1024
Changes from 1 commit
28a6f3b
b8eb753
e6896ef
48c61a7
aabde7f
0d60379
0b5f84d
7e01230
a116369
c8281ba
794cb34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,18 +106,24 @@ static void load_config_file( const fc::path& config_ini_path, const bpo::option | |
|
||
// get the basic options | ||
bpo::store(bpo::parse_config_file<char>(config_ini_path.preferred_string().c_str(), | ||
unique_options, true), options); | ||
unique_options, true), options); | ||
} | ||
|
||
static void load_logging_config_file | ||
( | ||
const fc::path& config_ini_path | ||
) | ||
{ | ||
// try to get logging options from the config file. | ||
try | ||
{ | ||
fc::optional<fc::logging_config> logging_config = load_logging_config_from_ini_file(config_ini_path); | ||
if (logging_config) | ||
fc::configure_logging(*logging_config); | ||
} | ||
catch (const fc::exception&) | ||
catch (const fc::exception& ex) | ||
{ | ||
wlog("Error parsing logging config from config file ${config}, using default config", ("config", config_ini_path.preferred_string())); | ||
wlog("Error parsing logging config from logging config file ${config}, using default config", ("config", config_ini_path.preferred_string())); | ||
} | ||
} | ||
|
||
|
@@ -169,12 +175,25 @@ static void create_new_config_file( const fc::path& config_ini_path, const fc::p | |
} | ||
out_cfg << "\n"; | ||
} | ||
|
||
out_cfg.close(); | ||
} | ||
|
||
static void create_logging_config_file | ||
( | ||
const fc::path& config_ini_path, | ||
const fc::path& data_dir | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style - same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
{ | ||
ilog("Writing new config file at ${path}", ("path", config_ini_path)); | ||
if (!exists(data_dir)) | ||
{ | ||
create_directories(data_dir); | ||
} | ||
|
||
std::ofstream out_cfg(config_ini_path.preferred_string()); | ||
write_default_logging_config_to_stream(out_cfg); | ||
out_cfg.close(); | ||
// read the default logging config we just wrote out to the file and start using it | ||
fc::optional<fc::logging_config> logging_config = load_logging_config_from_ini_file(config_ini_path); | ||
if (logging_config) | ||
fc::configure_logging(*logging_config); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
|
@@ -239,11 +258,21 @@ int main(int argc, char** argv) { | |
data_dir = fc::current_path() / data_dir; | ||
} | ||
|
||
// load witness node initial configuration | ||
fc::path config_ini_path = data_dir / "config.ini"; | ||
if( !fc::exists(config_ini_path) ) | ||
create_new_config_file( config_ini_path, data_dir, cfg_options ); | ||
load_config_file( config_ini_path, cfg_options, options ); | ||
|
||
// load witness node logging configuration | ||
const auto logging_ini_path = data_dir / "logging.ini"; | ||
if (!exists(logging_ini_path)) | ||
{ | ||
create_logging_config_file (logging_ini_path, data_dir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the logging parameters that already exist in the config.ini? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's right, our change doesn't handle it because we do not need to consider such use case, I can help with implementation if confirmed this is the way to go - I see some discussions still pending in #149 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the consensus of #149 is:
@pmconrad @abitmore @ryanRfox please verify that consensus has been reached, and my pseudo-code meets the requirements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, @jmjatlanta I agree with your pseudo-code above. Build that for #149. Notes for a future Enhancement Request:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the implementation extended to include the case when logging parameters already exist in the config.ini |
||
} | ||
|
||
load_logging_config_file( logging_ini_path ); | ||
|
||
bpo::notify(options); | ||
node->initialize(data_dir, options); | ||
node->initialize_plugins( options ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style - parameters on same line, if they fit, makes it easier to distinguish this as a function declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed