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

Function _printf

Engine/source/console/console.cpp:643–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641//------------------------------------------------------------------------------
642
643static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, const char* fmt, va_list argptr)
644{
645 if (!active)
646 return;
647 Con::active = false;
648
649 char buffer[8192];
650 U32 offset = 0;
651 if( gEvalState.traceOn && gEvalState.getStackDepth() > 0 )
652 {
653 offset = gEvalState.getStackDepth() * 3;
654 for(U32 i = 0; i < offset; i++)
655 buffer[i] = ' ';
656 }
657
658 if (useRealTimestamp)
659 {
660 Platform::LocalTime lt;
661 Platform::getLocalTime(lt);
662 offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[%d-%d-%d %02d:%02d:%02d]", lt.year + 1900, lt.month + 1, lt.monthday, lt.hour, lt.min, lt.sec);
663 }
664
665 if (useTimestamp)
666 {
667 static U32 startTime = Platform::getRealMilliseconds();
668 U32 curTime = Platform::getRealMilliseconds() - startTime;
669 offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[+%4d.%03d]", U32(curTime * 0.001), curTime % 1000);
670 }
671
672 if (useTimestamp || useRealTimestamp) {
673 offset += dSprintf(buffer + offset, sizeof(buffer) - offset, " ");
674 }
675
676
677 dVsprintf(buffer + offset, sizeof(buffer) - offset, fmt, argptr);
678
679 for(S32 i = 0; i < gConsumers.size(); i++)
680 gConsumers[i](level, buffer);
681
682 if(logBufferEnabled || consoleLogMode)
683 {
684 char *pos = buffer;
685 while(*pos)
686 {
687 if(*pos == '\t')
688 *pos = '^';
689 pos++;
690 }
691 pos = buffer;
692
693 for(;;)
694 {
695 char *eofPos = dStrchr(pos, '\n');
696 if(eofPos)
697 *eofPos = 0;
698
699 log(pos);
700 if(logBufferEnabled && !consoleLogLocked)

Callers 3

printfFunction · 0.85
warnfFunction · 0.85
errorfFunction · 0.85

Calls 11

dSprintfFunction · 0.85
dVsprintfFunction · 0.85
dStrcpyFunction · 0.85
getStackDepthMethod · 0.80
logFunction · 0.70
U32Enum · 0.50
dStrchrFunction · 0.50
dStrlenFunction · 0.50
sizeMethod · 0.45
allocMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected