Create time_log() to return a timeval so I can implement this on windows as well.

Originally committed to SVN as r4391.
This commit is contained in:
Amar Takhar 2010-06-01 05:11:18 +00:00
parent ac42fcda5d
commit 37b904b75e
4 changed files with 20 additions and 3 deletions

View file

@ -25,6 +25,7 @@
#include "libaegisub/log.h"
#include "libaegisub/mutex.h"
#include "libaegisub/util.h"
namespace agi {
namespace log {
@ -129,7 +130,7 @@ Message::Message(const char *section,
buf = new char[len];
msg = new std::ostrstream(buf, len);
timeval tv;
gettimeofday(&tv, (struct timezone *)NULL);
util::time_log(tv);
sm = new SinkMessage(section, severity, file, func, line, tv);
}

View file

@ -19,6 +19,13 @@
/// @ingroup libaegisub
#ifndef LAGI_PRE
#include <stdio.h>
#ifdef _WIN32
# include <time.h>
#else
# include <sys/time.h>
#endif // _WIN32
#include <deque>
#ifdef __DEPRECATED // Dodge GCC warnings
# undef __DEPRECATED

View file

@ -21,7 +21,12 @@
#ifndef LAGI_PRE
#include <string>
#include <stdio.h>
#endif
#ifdef _WIN32
# include <time.h>
#else
# include <sys/time.h>
#endif // _WIN32
#endif // LAGI_PRE
#include <libaegisub/access.h>
@ -30,7 +35,7 @@ namespace agi {
const std::string DirName(const std::string& path);
void Rename(const std::string& from, const std::string& to);
void time_log(timeval &tv);
} // namespace util
} // namespace agi

View file

@ -55,5 +55,9 @@ void Rename(const std::string& from, const std::string& to) {
rename(from.c_str(), to.c_str());
}
void time_log(timeval &tv) {
gettimeofday(&tv, (struct timezone *)NULL);
}
} // namespace io
} // namespace agi