Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks some of the handling for timestamp stuff #1076

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Engine/source/console/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ bool alwaysUseDebugOutput = true;
bool useTimestamp = false;
bool useRealTimestamp = false;

static U32 initTime = Platform::getRealMilliseconds();
U32 startTime = initTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be static U32 startTime = initTime; to avoid name collision outside of source file.


ConsoleFunctionGroupBegin( Clipboard, "Miscellaneous functions to control the clipboard and clear the console.");

DefineEngineFunction( cls, void, (), , "()"
Expand All @@ -327,14 +330,28 @@ DefineEngineFunction( getClipboard, const char*, (), , "()"
};

DefineEngineFunction( setClipboard, bool, (const char* text), , "(string text)"
"@brief Set the system clipboard.\n\n"
"@brief Set the system clipboard.\n\n"
"@internal")
{
return Platform::setClipboard(text);
};

ConsoleFunctionGroupEnd( Clipboard );

DefineEngineFunction( resetTimeStamp, void, (), , "()"
"@brief Reset the timestamp to 0 ms.\n\n"
"@ingroup Console")
{
startTime = Platform::getRealMilliseconds();
};

DefineEngineFunction( getInitTime, int, (), , "()"
"@brief Get the initialization time in miliseconds.\n\n"
"@internal")
{
return initTime;
};


void postConsoleInput( RawData data );

Expand Down Expand Up @@ -644,7 +661,7 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co
{
if (!active)
return;
Con::active = false;
Con::active = false;

char buffer[8192] = {};
U32 offset = 0;
Expand All @@ -664,16 +681,15 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co

if (useTimestamp)
{
static U32 startTime = Platform::getRealMilliseconds();
U32 curTime = Platform::getRealMilliseconds() - startTime;
offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[+%4d.%03d]", U32(curTime * 0.001), curTime % 1000);
}

if (useTimestamp || useRealTimestamp) {
if (useTimestamp || useRealTimestamp)
{
offset += dSprintf(buffer + offset, sizeof(buffer) - offset, " ");
}


dVsprintf(buffer + offset, sizeof(buffer) - offset, fmt, argptr);

for(S32 i = 0; i < gConsumers.size(); i++)
Expand Down Expand Up @@ -2652,3 +2668,5 @@ void ConsoleStackFrameSaver::restore()
gCallStack.popFrame();
}
}

//------------------------------------------------------------------------------
Loading