diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index 3443f1293d860..31c4a991cf822 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -24,6 +24,7 @@ #include "threads/Thread.h" #include "utils/StringUtils.h" #include "CompileInfo.h" +#include "utils/TimeUtils.cpp" static const char* const levelNames[] = {"DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "SEVERE", "FATAL", "NONE"}; @@ -198,19 +199,31 @@ void CLog::PrintDebugString(const std::string& line) bool CLog::WriteLogString(int logLevel, const std::string& logString) { +#if defined(TARGET_LINUX) + static const char* prefixFormat = "%02.2d:%02.2d:%02.2d %10.6f T:%" PRIu64" %7s: "; +#else static const char* prefixFormat = "%02.2d:%02.2d:%02.2d T:%" PRIu64" %7s: "; - +#endif std::string strData(logString); /* fixup newline alignment, number of spaces should equal prefix length */ StringUtils::Replace(strData, "\n", "\n "); int hour, minute, second; s_globals.m_platform.GetCurrentLocalTime(hour, minute, second); - + +#if defined(TARGET_LINUX) + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + float Now = now.tv_sec + now.tv_nsec * 1e-9; +#endif + strData = StringUtils::Format(prefixFormat, hour, minute, second, +#if defined(TARGET_LINUX) + Now, +#endif (uint64_t)CThread::GetCurrentThreadId(), levelNames[logLevel]) + strData;