summaryrefslogtreecommitdiff
path: root/src/log.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-11 15:47:35 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-11 15:47:35 +0000
commit8da32105732949b4b0273c718d118bcfae70a1c9 (patch)
tree0a354974d48268cfaafcdb1e06b498fa26a59c1e /src/log.cpp
parentf9ce4e302cb3ed203d89a7a18e10b7ad4f11519c (diff)
downloadmana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.gz
mana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.bz2
mana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.xz
mana-8da32105732949b4b0273c718d118bcfae70a1c9.zip
Merged 0.0 changes from revision 2825 to 2898 to trunk.
Diffstat (limited to 'src/log.cpp')
-rw-r--r--src/log.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/log.cpp b/src/log.cpp
index 07eb55f7..3a3c91b8 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -21,7 +21,9 @@
#include "log.h"
#ifdef WIN32
-#include <windows.h>
+ #include "utils/wingettimeofday.h"
+#else
+ #include <sys/time.h>
#endif
#ifdef __APPLE__
#include <Carbon/Carbon.h>
@@ -64,7 +66,6 @@ void Logger::log(const char *log_text, ...)
char* buf = new char[1024];
va_list ap;
- time_t t;
// Use a temporary buffer to fill in the variables
va_start(ap, log_text);
@@ -72,19 +73,23 @@ void Logger::log(const char *log_text, ...)
va_end(ap);
// Get the current system time
- time(&t);
+ timeval tv;
+ gettimeofday(&tv, NULL);
// Print the log entry
std::stringstream timeStr;
timeStr << "["
- << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
- << (int)(((t / 60) / 60) % 24)
+ << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "")
+ << (int)(((tv.tv_sec / 60) / 60) % 24)
<< ":"
- << (((t / 60) % 60 < 10) ? "0" : "")
- << (int)((t / 60) % 60)
+ << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "")
+ << (int)((tv.tv_sec / 60) % 60)
<< ":"
- << ((t % 60 < 10) ? "0" : "")
- << (int)(t % 60)
+ << ((tv.tv_sec % 60 < 10) ? "0" : "")
+ << (int)(tv.tv_sec % 60)
+ << "."
+ << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "")
+ << (int)((tv.tv_usec / 10000) % 100)
<< "] ";
mLogFile << timeStr.str() << buf << std::endl;