summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-04-22 15:45:05 +0000
committerChris Wilson <chris+github@qwirx.com>2007-04-22 15:45:05 +0000
commitf8d41c2eec776ce3c9920fd01fd3971dc99cf531 (patch)
tree853981ad8a94cb8cc730f1ab15f0579f95de8e82
parent1a99df430cd17693e2829ab45b1d46d27b92be0c (diff)
Compile fix for Win32, where no localtime_r is available and localtime
is thread safe. (refs #3)
-rw-r--r--lib/common/Logging.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp
index 4078a679..bb728183 100644
--- a/lib/common/Logging.cpp
+++ b/lib/common/Logging.cpp
@@ -210,7 +210,7 @@ bool Console::Log(Log::Level level, const std::string& rFile,
if (sShowTime)
{
- struct tm time_now;
+ struct tm time_now, *tm_ptr = &time_now;
time_t time_t_now = time(NULL);
if (time_t_now == ((time_t)-1))
@@ -218,13 +218,17 @@ bool Console::Log(Log::Level level, const std::string& rFile,
msg += strerror(errno);
msg += " ";
}
- else if (localtime_r(&time_t_now, &time_now) != NULL)
+ #ifdef WIN32
+ else if ((tm_ptr = localtime(&time_t_now)) != NULL)
+ #else
+ else if (localtime_r(&time_t_now, &time_now) != NULL)
+ #endif
{
std::ostringstream buf;
buf << std::setfill('0') <<
- std::setw(2) << time_now.tm_hour << ":" <<
- std::setw(2) << time_now.tm_min << ":" <<
- std::setw(2) << time_now.tm_sec << " ";
+ std::setw(2) << tm_ptr->tm_hour << ":" <<
+ std::setw(2) << tm_ptr->tm_min << ":" <<
+ std::setw(2) << tm_ptr->tm_sec << " ";
msg += buf.str();
}
else