[Projet64] Make Trace.cpp more linux friendly

This commit is contained in:
zilmar 2016-01-13 06:02:18 +11:00
parent 8580a1d5ce
commit 3d29a5de52
2 changed files with 19 additions and 2 deletions

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include <windows.h>
typedef std::map<uint32_t, stdstr> ModuleNameMap;
@ -192,9 +191,23 @@ void CTraceFileLog::Write(uint32_t module, uint8_t severity, const char * /*file
{
if (!m_hLogFile.IsOpen()) { return; }
SYSTEMTIME sysTime;
#ifdef _WIN32
SYSTEMTIME sysTime;
::GetLocalTime(&sysTime);
stdstr_f timestamp("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d,", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds, GetCurrentThreadId());
#else
time_t ltime;
ltime=time(&ltime);
struct tm result={0};
localtime_r(&ltime, &result);
struct timeval curTime;
gettimeofday(&curTime, NULL);
int milliseconds = curTime.tv_usec / 1000;
stdstr_f timestamp("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d,", result.tm_year+1900, result.tm_mon+1, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec, milliseconds, GetCurrentThreadId());
#endif
m_hLogFile.Log(timestamp.c_str());
m_hLogFile.Log(TraceSeverity(severity));

View File

@ -11,6 +11,10 @@ enum TraceSeverity
TraceVerbose = 0x00000006,
};
#ifndef _MSC_VER
#define __interface struct
#endif
__interface CTraceModule
{
virtual void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message) = 0;