From afa81243015bcb691a32a2e0650f76af61a244f5 Mon Sep 17 00:00:00 2001 From: Tony <1414927+zfbTony@users.noreply.github.com> Date: Sat, 24 Oct 2020 05:41:18 -0400 Subject: [PATCH 1/3] Added date/time stamps option to console log --- Engine/source/console/console.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index a383ae524..8916699ba 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -275,6 +275,7 @@ S32 gObjectCopyFailures = -1; bool alwaysUseDebugOutput = true; bool useTimestamp = false; +bool useRealTimestamp = false; ConsoleFunctionGroupBegin( Clipboard, "Miscellaneous functions to control the clipboard and clear the console."); @@ -374,6 +375,10 @@ void init() addVariable("Con::useTimestamp", TypeBool, &useTimestamp, "If true a timestamp is prepended to every console message.\n" "@ingroup Console\n"); + // controls whether a real date and time is prepended to every console message + addVariable("Con::useRealTimestamp", TypeBool, &useRealTimestamp, "If true a date and time will be prepended to every console message.\n" + "@ingroup Console\n"); + // Plug us into the journaled console input signal. smConsoleInput.notify(postConsoleInput); } @@ -612,6 +617,13 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co buffer[i] = ' '; } + if (useRealTimestamp) + { + Platform::LocalTime lt; + Platform::getLocalTime(lt); + offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[%d/%d/%d %02d:%02d:%02d]", lt.monthday, lt.month + 1, lt.year + 1900, lt.hour, lt.min, lt.sec); + } + if (useTimestamp) { static U32 startTime = Platform::getRealMilliseconds(); From f7a0047391444b3a28d3f2e89412eabc64b0e241 Mon Sep 17 00:00:00 2001 From: Tony <1414927+zfbTony@users.noreply.github.com> Date: Sat, 24 Oct 2020 20:34:03 -0400 Subject: [PATCH 2/3] Fixed date order to be YYYY/MM/DD --- Engine/source/console/console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index 8916699ba..e0b4dce2a 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -621,7 +621,7 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co { Platform::LocalTime lt; Platform::getLocalTime(lt); - offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[%d/%d/%d %02d:%02d:%02d]", lt.monthday, lt.month + 1, lt.year + 1900, lt.hour, lt.min, lt.sec); + 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); } if (useTimestamp) From a5b31a3cef255b31cc8544cd2d6f3e3a4e3905be Mon Sep 17 00:00:00 2001 From: Tony <1414927+zfbTony@users.noreply.github.com> Date: Sat, 24 Oct 2020 20:39:27 -0400 Subject: [PATCH 3/3] Added space to append to timestamps if they're used --- Engine/source/console/console.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index e0b4dce2a..4d6519514 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -621,7 +621,7 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co { Platform::LocalTime lt; Platform::getLocalTime(lt); - 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); + 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); } if (useTimestamp) @@ -630,6 +630,12 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co U32 curTime = Platform::getRealMilliseconds() - startTime; offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[+%4d.%03d]", U32(curTime * 0.001), curTime % 1000); } + + 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++)