MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / log

Function log

Engine/source/console/console.cpp:581–639  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

579
580//------------------------------------------------------------------------------
581static void log(const char *string)
582{
583 // Bail if we ain't logging.
584 if (!consoleLogMode)
585 {
586 return;
587 }
588
589 // In mode 1, we open, append, close on each log write.
590 if ((consoleLogMode & 0x3) == 1)
591 {
592 consoleLogFile.open(defLogFileName, Torque::FS::File::ReadWrite);
593 }
594
595 // Write to the log if its status is hunky-dory.
596 if ((consoleLogFile.getStatus() == Stream::Ok) || (consoleLogFile.getStatus() == Stream::EOS))
597 {
598 consoleLogFile.setPosition(consoleLogFile.getStreamSize());
599 // If this is the first write...
600 if (newLogFile)
601 {
602 // Make a header.
603 Platform::LocalTime lt;
604 Platform::getLocalTime(lt);
605 char buffer[128];
606 dSprintf(buffer, sizeof(buffer), "//-------------------------- %d/%d/%d -- %02d:%02d:%02d -----\r\n",
607 lt.month + 1,
608 lt.monthday,
609 lt.year + 1900,
610 lt.hour,
611 lt.min,
612 lt.sec);
613 consoleLogFile.write(dStrlen(buffer), buffer);
614 newLogFile = false;
615 if (consoleLogMode & 0x4)
616 {
617 // Dump anything that has been printed to the console so far.
618 consoleLogMode -= 0x4;
619 U32 size, line;
620 ConsoleLogEntry *log;
621 getLockLog(log, size);
622 for (line = 0; line < size; line++)
623 {
624 consoleLogFile.write(dStrlen(log[line].mString), log[line].mString);
625 consoleLogFile.write(2, "\r\n");
626 }
627 unlockLog();
628 }
629 }
630 // Now write what we came here to write.
631 consoleLogFile.write(dStrlen(string), string);
632 consoleLogFile.write(2, "\r\n");
633 }
634
635 if ((consoleLogMode & 0x3) == 1)
636 {
637 consoleLogFile.close();
638 }

Callers 15

_printfFunction · 0.70
enableMethod · 0.50
createMethod · 0.50
destroyMethod · 0.50
acquireMethod · 0.50
unacquireMethod · 0.50
enumerateObjectsMethod · 0.50
processAsyncMethod · 0.50
processImmediateMethod · 0.50
buildEventMethod · 0.50
rumbleMethod · 0.50
enableMethod · 0.50

Calls 10

dSprintfFunction · 0.85
getLockLogFunction · 0.85
unlockLogFunction · 0.85
openMethod · 0.65
closeMethod · 0.65
dStrlenFunction · 0.50
getStatusMethod · 0.45
setPositionMethod · 0.45
getStreamSizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected