Added timestamp in log #4845

This commit is contained in:
Jerry (Xinyu Hou)
2015-07-06 15:50:21 -07:00
parent 23739f8484
commit 260a7337d3
3 changed files with 14 additions and 6 deletions

View File

@@ -174,16 +174,17 @@ Log::print(const char* file, int line, const char* fmt, ...)
char message[kLogMessageLength];
#ifndef NDEBUG
struct tm *tm;
char tmp[220];
time_t t;
time(&t);
tm = localtime(&t);
sprintf(tmp, "%04i-%02i-%02iT%02i:%02i:%02i", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
sprintf(message, "%s %s: %s\n\t%s,%d", tmp, g_priority[priority], buffer, file, line);
#ifndef NDEBUG
sprintf(message, "[%s] %s: %s\n\t%s,%d", tmp, g_priority[priority], buffer, file, line);
#else
sprintf(message, "%s: %s", g_priority[priority], buffer);
sprintf(message, "[%s] %s: %s", tmp, g_priority[priority], buffer);
#endif
output(priority, message);