MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / StartLogging

Function StartLogging

src/init/common.cpp:107–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool 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
148void LogPackageVersion()
149{

Callers 2

DisableLoggingMethod · 0.85
AppInitMainFunction · 0.85

Calls 15

InitErrorFunction · 0.85
UntranslatedFunction · 0.85
PathToStringFunction · 0.85
FormatISO8601DateTimeFunction · 0.85
GetDefaultDataDirFunction · 0.85
existsFunction · 0.85
InitWarningFunction · 0.85
_Function · 0.85
GetBoolArgMethod · 0.80
ShrinkDebugFileMethod · 0.80
StartLoggingMethod · 0.80

Tested by

no test coverage detected