| 105 | } |
| 106 | |
| 107 | bool StartLogging(const ArgsManager& args) |
| 108 | { |
| 109 | if (LogInstance().m_print_to_file) { |
| 110 | if (args.GetBoolArg("-shrinkdebugfile", LogInstance().DefaultShrinkDebugFile())) { |
| 111 | // Do this first since it both loads a bunch of debug.log into memory, |
| 112 | // and because this needs to happen before any other debug.log printing |
| 113 | LogInstance().ShrinkDebugFile(); |
| 114 | } |
| 115 | } |
| 116 | if (!LogInstance().StartLogging()) { |
| 117 | return InitError(Untranslated(strprintf("Could not open debug log file %s", |
| 118 | fs::PathToString(LogInstance().m_file_path)))); |
| 119 | } |
| 120 | |
| 121 | if (!LogInstance().m_log_timestamps) { |
| 122 | LogInfo("Startup time: %s", FormatISO8601DateTime(GetTime())); |
| 123 | } |
| 124 | LogInfo("Default data directory %s", fs::PathToString(GetDefaultDataDir())); |
| 125 | LogInfo("Using data directory %s", fs::PathToString(gArgs.GetDataDirNet())); |
| 126 | |
| 127 | // Only log conf file usage message if conf file actually exists. |
| 128 | fs::path config_file_path = args.GetConfigFilePath(); |
| 129 | if (args.IsArgNegated("-conf")) { |
| 130 | LogInfo("Config file: <disabled>"); |
| 131 | } else if (fs::is_directory(config_file_path)) { |
| 132 | LogWarning("Config file: %s (is directory, not file)", fs::PathToString(config_file_path)); |
| 133 | } else if (fs::exists(config_file_path)) { |
| 134 | LogInfo("Config file: %s", fs::PathToString(config_file_path)); |
| 135 | } else if (args.IsArgSet("-conf")) { |
| 136 | InitWarning(strprintf(_("The specified config file %s does not exist"), fs::PathToString(config_file_path))); |
| 137 | } else { |
| 138 | // Not categorizing as "Warning" because it's the default behavior |
| 139 | LogInfo("Config file: %s (not found, skipping)", fs::PathToString(config_file_path)); |
| 140 | } |
| 141 | |
| 142 | // Log the config arguments to debug.log |
| 143 | args.LogArgs(); |
| 144 | |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | void LogPackageVersion() |
| 149 | { |
no test coverage detected