| 120 | } |
| 121 | |
| 122 | bool StartLogging(const ArgsManager& args) |
| 123 | { |
| 124 | if (LogInstance().m_print_to_file) { |
| 125 | if (args.GetBoolArg("-shrinkdebugfile", LogInstance().DefaultShrinkDebugFile())) { |
| 126 | // Do this first since it both loads a bunch of debug.log into memory, |
| 127 | // and because this needs to happen before any other debug.log printing |
| 128 | LogInstance().ShrinkDebugFile(); |
| 129 | } |
| 130 | } |
| 131 | if (!LogInstance().StartLogging()) { |
| 132 | return InitError(strprintf(Untranslated("Could not open debug log file %s"), |
| 133 | fs::PathToString(LogInstance().m_file_path))); |
| 134 | } |
| 135 | |
| 136 | if (!LogInstance().m_log_timestamps) |
| 137 | LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime())); |
| 138 | LogPrintf("Default data directory %s\n", fs::PathToString(GetDefaultDataDir())); |
| 139 | LogPrintf("Using data directory %s\n", fs::PathToString(gArgs.GetDataDirNet())); |
| 140 | |
| 141 | // Only log conf file usage message if conf file actually exists. |
| 142 | fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME)); |
| 143 | if (fs::exists(config_file_path)) { |
| 144 | LogPrintf("Config file: %s\n", fs::PathToString(config_file_path)); |
| 145 | } else if (args.IsArgSet("-conf")) { |
| 146 | // Warn if no conf file exists at path provided by user |
| 147 | InitWarning(strprintf(_("The specified config file %s does not exist"), fs::PathToString(config_file_path))); |
| 148 | } else { |
| 149 | // Not categorizing as "Warning" because it's the default behavior |
| 150 | LogPrintf("Config file: %s (not found, skipping)\n", fs::PathToString(config_file_path)); |
| 151 | } |
| 152 | |
| 153 | // Log the config arguments to debug.log |
| 154 | args.LogArgs(); |
| 155 | |
| 156 | return true; |
| 157 | } |
| 158 | |
| 159 | void LogPackageVersion() |
| 160 | { |
no test coverage detected