How to added milleseconds to time format

10 views
Skip to first unread message

Alexandr Gordienko

unread,
Feb 25, 2019, 12:25:34 AM2/25/19
to Logog
Hi, you need to add milliseconds to the time format, how to do this?
        LOGOG_INITIALIZE();
    {
              logog::Formatter * pFormatter = &(logog::GetDefaultFormatter());
               pFormatter->SetShowTimeOfDay(true);
            logog::LogFile logFile("log.txt");
             pFormatter->SetTimeOfDayFormat("%Y-%m-%d %H:%M:%S");    //%Y-%m-%d %H:%M:%S.{milliseconds}-how to added milliseconds?
            for (int i = 0; i < 100; ++i)
                  INFO("Test string %i", i);
 }
      LOGOG_SHUTDOWN();


Alexandr Gordienko

unread,
Mar 5, 2019, 10:13:27 PM3/5/19
to Logog
void MyFormatter::RenderTimeOfDay()
{
if (m_bShowTimeOfDay)
{
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
char buf[30];
snprintf(buf, 30, "%u-%02u-%02u %02u:%02u:%02u.%u",sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour, sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds);
m_sMessageBuffer.append(buf);
m_sMessageBuffer.append(": ");
}
}

понедельник, 25 февраля 2019 г., 12:25:34 UTC+7 пользователь Alexandr Gordienko написал:
Reply all
Reply to author
Forward
0 new messages