MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / LogPrintStr

Function LogPrintStr

src/util.cpp:279–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279int LogPrintStr(const std::string &str)
280{
281 int ret = 0; // Returns total number of characters written
282 static bool fStartedNewLine = true;
283
284 string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
285
286 if (fPrintToConsole)
287 {
288 // print to console
289 ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
290 fflush(stdout);
291 }
292 else if (fPrintToDebugLog)
293 {
294 boost::call_once(&DebugPrintInit, debugPrintInitFlag);
295 boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);
296
297 // buffer if we haven't opened the log yet
298 if (fileout == NULL) {
299 assert(vMsgsBeforeOpenLog);
300 ret = strTimestamped.length();
301 vMsgsBeforeOpenLog->push_back(strTimestamped);
302 }
303 else
304 {
305 // reopen the log file, if requested
306 if (fReopenDebugLog) {
307 fReopenDebugLog = false;
308 boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
309 if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL)
310 setbuf(fileout, NULL); // unbuffered
311 }
312
313 ret = FileWriteStr(strTimestamped, fileout);
314 }
315 }
316 return ret;
317}
318
319/** Interpret string as boolean, for argument parsing */
320static bool InterpretBool(const std::string& strValue)

Callers 2

util.hFile · 0.85
errorFunction · 0.85

Calls 5

LogTimestampStrFunction · 0.85
FileWriteStrFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected