From bfccdad07b9a02271f3b0ede660a1abee66eb9b1 Mon Sep 17 00:00:00 2001 From: jjl77 Date: Thu, 19 Sep 2019 10:15:09 -0700 Subject: [PATCH] Fixed issue with incorrect time in log messages --- ek9000App/src/devEK9000.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ek9000App/src/devEK9000.cpp b/ek9000App/src/devEK9000.cpp index 1ba44ab..9fbfee0 100644 --- a/ek9000App/src/devEK9000.cpp +++ b/ek9000App/src/devEK9000.cpp @@ -134,11 +134,12 @@ void Info(const char* fmt, ...) } void Warning(const char* fmt, ...) -{ - time_t clk = time(0); - tm _tm; - epicsTime_localtime(&clk, &_tm); - epicsPrintf("%i/%i/%i %i:%i:%i [WARN] ", _tm.tm_mday, _tm.tm_mon, _tm.tm_year, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); +{ + epicsTimeStamp stmp; + epicsTimeGetCurrent(&stmp); + char txt[40]; + epicsTimeToStrftime(txt, 40, "%Y/%m/%d %H:%M:%S.%03f ", &stmp); + epicsPrintf("%s", txt); va_list list; va_start(list, fmt); epicsVprintf(fmt, list); @@ -147,10 +148,11 @@ void Warning(const char* fmt, ...) void Error(const char* fmt, ...) { - time_t clk = time(0); - tm _tm; - epicsTime_localtime(&clk, &_tm); - epicsPrintf("%i/%i/%i %i:%i:%i [ERROR] ", _tm.tm_mday, _tm.tm_mon, _tm.tm_year, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + epicsTimeStamp stmp; + epicsTimeGetCurrent(&stmp); + char txt[40]; + epicsTimeToStrftime(txt, 40, "%Y/%m/%d %H:%M:%S.%03f ", &stmp); + epicsPrintf("%s", txt); va_list list; va_start(list, fmt); epicsVprintf(fmt, list);