浏览代码

2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Assign the value of tv.tv_sec to time_t timesec instead of
	giving tv.tv_sec to localtime_r directly because tv.tv_sec may
	not be  of type time_t.
	* src/SimpleLogger.cc
Tatsuhiro Tsujikawa 16 年之前
父节点
当前提交
43796accda
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 7 0
      ChangeLog
  2. 3 1
      src/SimpleLogger.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2009-02-12  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Assign the value of tv.tv_sec to time_t timesec instead of giving
+	tv.tv_sec to localtime_r directly because tv.tv_sec may not be of
+	type time_t.
+	* src/SimpleLogger.cc
+	
 2009-02-11  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Added test for FtpConnection::receiveSizeResponse().

+ 3 - 1
src/SimpleLogger.cc

@@ -147,7 +147,9 @@ void SimpleLogger::writeLog(std::ostream& o, Logger::LEVEL level,
   gettimeofday(&tv, 0);
   char datestr[27]; // 'YYYY-MM-DD hh:mm:ss.uuuuuu'+'\0' = 27 bytes
   struct tm tm;
-  localtime_r(&tv.tv_sec, &tm);
+  //tv.tv_sec may not be of type time_t.
+  time_t timesec = tv.tv_sec;
+  localtime_r(&timesec, &tm);
   size_t dateLength =
     strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
   assert(dateLength <= (size_t)20);