From 946107a68ffce8c586f9f1657fd7d67d075c321e Mon Sep 17 00:00:00 2001 From: Alexander Leishman Date: Fri, 24 Aug 2018 15:03:01 -0700 Subject: [PATCH] Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exists. This commit changes the logic to only display this message if a config file exists and logs a separate message if no config file exists. Additionally, a warning is now logged if the file path passed in the -conf flag does not exist. --- src/init.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index bd330459f6..d4833f029c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1243,7 +1243,19 @@ bool AppInitMain() LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime())); LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); LogPrintf("Using data directory %s\n", GetDataDir().string()); - LogPrintf("Using config file %s\n", GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string()); + + // Only log conf file usage message if conf file actually exists. + fs::path config_file_path = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)); + if (fs::exists(config_file_path)) { + LogPrintf("Config file: %s\n", config_file_path.string()); + } else if (gArgs.IsArgSet("-conf")) { + // Warn if no conf file exists at path provided by user + InitWarning(strprintf(_("The specified config file %s does not exist\n"), config_file_path.string())); + } else { + // Not categorizing as "Warning" because it's the default behavior + LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string()); + } + LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); // Warn about relative -datadir path.