From 46567b70fedc89ffc609812d2c3534bfbaada7f8 Mon Sep 17 00:00:00 2001 From: Andrey Kazmin Date: Mon, 23 Dec 2019 13:32:58 +0300 Subject: Fixed missed initialization of struct tm in Logger::timeStamp Signed-off-by: Andrey Kazmin --- core/Logger/Logger.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/Logger/Logger.cpp b/core/Logger/Logger.cpp index 96c1e9b..2394c5a 100755 --- a/core/Logger/Logger.cpp +++ b/core/Logger/Logger.cpp @@ -155,13 +155,15 @@ int Logger::registerLogger(AbstractLogger *l) { } std::string Logger::timeStamp() { - struct tm b; + struct tm *b; struct timeval detail_time; + gettimeofday(&detail_time, NULL); + b = gmtime(&detail_time.tv_sec); char buf[80]; // strftime(buf, sizeof(buf), "%d/%m/%y,%T ", brokenTime, detail_time.tv_usec/1000); - snprintf(buf, sizeof(buf), "[%d/%d/%d,%d:%d:%d.%ld]", b.tm_year, b.tm_mon, b.tm_mday, b.tm_hour, b.tm_min, b.tm_sec, detail_time.tv_usec/1000); + snprintf(buf, sizeof(buf), "[%d/%d/%d,%d:%d:%d.%ld]", b->tm_year, b->tm_mon, b->tm_mday, b->tm_hour, b->tm_min, b->tm_sec, detail_time.tv_usec/1000); return std::string(buf); } -- cgit v1.2.3