MCPcopy Create free account
hub / github.com/LUX-Core/lux / LogPrintStr

Function LogPrintStr

src/util.cpp:281–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281int LogPrintStr(const std::string& str, bool useVMLog)
282{
283//////////////////////////////// // lux
284 if (fileout) {
285 int size = ftell(fileout);
286 if (size >= MAX_FILE_SIZE && nLogFile > 1) {
287 fclose(fileout);
288 boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
289 std::string pathDebugStr = pathDebug.string();
290 int debugNum = 1;
291 while (true) {
292 std::string tempPath = pathDebugStr + ".";
293 if (debugNum < 10)
294 tempPath += "0";
295 tempPath += std::to_string(debugNum);
296 if (access( tempPath.c_str(), F_OK ) != -1)
297 debugNum++;
298 else if (debugNum < nLogFile) {
299 pushDebugLog(pathDebugStr, debugNum);
300 break;
301 } else {
302 pushDebugLog(pathDebugStr, nLogFile - 1);
303 break;
304 }
305 }
306 std::string nextPathDebugStr = pathDebugStr + ".01";
307 if (access( nextPathDebugStr.c_str(), F_OK ) != -1)
308 remove(nextPathDebugStr.c_str());
309 rename(pathDebugStr.c_str(), nextPathDebugStr.c_str());
310 fileout = fopen(pathDebugStr.c_str(), "wa");
311 if (fileout) setbuf(fileout, NULL); // unbuffered
312 }
313 }
314
315 FILE* file = fileout;
316 if(useVMLog){
317 file = fileoutVM;
318 }
319////////////////////////////////
320
321 int ret = 0; // Returns total number of characters written
322 if (fPrintToConsole) {
323 // print to console
324 ret = fwrite(str.data(), 1, str.size(), stdout);
325 fflush(stdout);
326 } else if (fPrintToDebugLog && AreBaseParamsConfigured()) {
327 static bool fStartedNewLine = true;
328 boost::call_once(&DebugPrintInit, debugPrintInitFlag);
329
330 if (file == NULL)
331 return ret;
332
333 boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);
334
335 // reopen the log file, if requested
336 if (fReopenDebugLog) {
337 fReopenDebugLog = false;
338 boost::filesystem::path pathDebug = GetDataDir() / "debug.log";

Callers 4

AppInit2Function · 0.85
util.hFile · 0.85
errorFunction · 0.85
LogPrintFunction · 0.85

Calls 7

pushDebugLogFunction · 0.85
AreBaseParamsConfiguredFunction · 0.85
DateTimeStrFormatFunction · 0.85
GetTimeFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected