diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index a13f3a9dad..a8c28eb6bf 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -10,8 +10,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #ifdef _WIN32 #include #define getpid _getpid @@ -21,6 +19,7 @@ #include // for getpid() on linux #endif +#include #include #include @@ -38,6 +37,10 @@ LogHandler::LogHandler() : QTimer* logFlushTimer = new QTimer(this); connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages); logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000); + + // when the log handler is first setup we should print our timezone + QString timezoneString = "Time zone: " + QDateTime::currentDateTime().toString("t"); + printf("%s\n", qPrintable(timezoneString)); } const char* stringForLogType(LogMsgType msgType) { @@ -57,8 +60,8 @@ const char* stringForLogType(LogMsgType msgType) { } } -// the following will produce 2000-10-02 13:55:36 -0700 -const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z"; +// the following will produce 11/18 13:55:36 +const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss"; void LogHandler::flushRepeatedMessages() { QHash::iterator message = _repeatMessageCountHash.begin(); @@ -112,14 +115,7 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont QString prefixString = QString("[%1]").arg(stringForLogType(type)); - time_t rawTime; - time(&rawTime); - struct tm* localTime = localtime(&rawTime); - - char dateString[100]; - strftime(dateString, sizeof(dateString), DATE_STRING_FORMAT, localTime); - - prefixString.append(QString(" [%1]").arg(dateString)); + prefixString.append(QString(" [%1]").arg(QDateTime::currentDateTime().toString(DATE_STRING_FORMAT))); if (_shouldOutputPID) { prefixString.append(QString(" [%1").arg(getpid()));