summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common/BoxTime.cpp14
-rw-r--r--lib/common/BoxTime.h3
-rw-r--r--lib/common/Logging.cpp4
-rw-r--r--lib/common/Timer.cpp2
4 files changed, 16 insertions, 7 deletions
diff --git a/lib/common/BoxTime.cpp b/lib/common/BoxTime.cpp
index 0d099db5..d05c0a6c 100644
--- a/lib/common/BoxTime.cpp
+++ b/lib/common/BoxTime.cpp
@@ -53,7 +53,7 @@ box_time_t GetCurrentBoxTime()
return SecondsToBoxTime(time(0));
}
-std::string FormatTime(box_time_t time, bool showMicros)
+std::string FormatTime(box_time_t time, bool includeDate, bool showMicros)
{
std::ostringstream buf;
@@ -68,8 +68,16 @@ std::string FormatTime(box_time_t time, bool showMicros)
if (localtime_r(&seconds, &tm_now) != NULL)
#endif
{
- buf << std::setfill('0') <<
- std::setw(2) << tm_ptr->tm_hour << ":" <<
+ buf << std::setfill('0');
+
+ if (includeDate)
+ {
+ buf << std::setw(4) << (tm_ptr->tm_year + 1900) << "-" <<
+ std::setw(2) << (tm_ptr->tm_mon + 1) << "-" <<
+ std::setw(2) << (tm_ptr->tm_mday) << " ";
+ }
+
+ buf << std::setw(2) << tm_ptr->tm_hour << ":" <<
std::setw(2) << tm_ptr->tm_min << ":" <<
std::setw(2) << tm_ptr->tm_sec;
diff --git a/lib/common/BoxTime.h b/lib/common/BoxTime.h
index 2023db36..6681bbbd 100644
--- a/lib/common/BoxTime.h
+++ b/lib/common/BoxTime.h
@@ -40,6 +40,7 @@ inline uint64_t BoxTimeToMicroSeconds(box_time_t Time)
return Time;
}
-std::string FormatTime(box_time_t time, bool showMicros = false);
+std::string FormatTime(box_time_t time, bool includeDate,
+ bool showMicros = false);
#endif // BOXTIME__H
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp
index 9248bd35..1f872d93 100644
--- a/lib/common/Logging.cpp
+++ b/lib/common/Logging.cpp
@@ -288,7 +288,7 @@ bool Console::Log(Log::Level level, const std::string& rFile,
if (sShowTime)
{
- buf << FormatTime(GetCurrentBoxTime(), sShowTimeMicros);
+ buf << FormatTime(GetCurrentBoxTime(), false, sShowTimeMicros);
buf << " ";
}
@@ -449,7 +449,7 @@ bool FileLogger::Log(Log::Level Level, const std::string& rFile,
Logging::Remove(this);
std::ostringstream buf;
- buf << FormatTime(GetCurrentBoxTime(), false);
+ buf << FormatTime(GetCurrentBoxTime(), true, false);
buf << " ";
if (Level <= Log::FATAL)
diff --git a/lib/common/Timer.cpp b/lib/common/Timer.cpp
index 01afa91b..137ad45f 100644
--- a/lib/common/Timer.cpp
+++ b/lib/common/Timer.cpp
@@ -357,7 +357,7 @@ Timer::Timer(size_t timeoutSecs, const std::string& rName)
else
{
BOX_TRACE(TIMER_ID "initialised for " << timeoutSecs <<
- " secs, to fire at " << FormatTime(mExpires, true));
+ " secs, to fire at " << FormatTime(mExpires, false, true));
}
#endif