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
pull/1/head
Tatsuhiro Tsujikawa 2009-02-11 16:05:33 +00:00
parent 0a5f6751d1
commit 43796accda
2 changed files with 10 additions and 1 deletions

View File

@ -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().

View File

@ -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);