mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-11 17:37:22 +10:00
Log: More precise timing
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
#include "ResourceHelper.h"
|
||||
#include "ComHelper.h"
|
||||
#include <propvarutil.h>
|
||||
#include <chrono>
|
||||
|
||||
int g_LogCategories;
|
||||
static FILE *g_LogFile;
|
||||
static int g_LogTime;
|
||||
static std::chrono::time_point<std::chrono::steady_clock> g_LogTime;
|
||||
|
||||
void InitLog( int categories, const wchar_t *fname )
|
||||
{
|
||||
@@ -23,7 +24,7 @@ void InitLog( int categories, const wchar_t *fname )
|
||||
wchar_t bom=0xFEFF;
|
||||
fwrite(&bom,2,1,g_LogFile);
|
||||
g_LogCategories=categories;
|
||||
g_LogTime=GetTickCount();
|
||||
g_LogTime=std::chrono::steady_clock::now();
|
||||
LogMessage(L"version=%x, PID=%d, TID=%d, Categories=%08x\r\n",GetWinVersion(),GetCurrentProcessId(),GetCurrentThreadId(),categories);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +41,7 @@ void LogMessage( const wchar_t *text, ... )
|
||||
if (!g_LogFile) return;
|
||||
|
||||
wchar_t buf[2048];
|
||||
int len=Sprintf(buf,_countof(buf),L"%8d: ",GetTickCount()-g_LogTime);
|
||||
int len=Sprintf(buf,_countof(buf),L"%8d: ",std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now()-g_LogTime).count());
|
||||
fwrite(buf,2,len,g_LogFile);
|
||||
|
||||
va_list args;
|
||||
|
||||
Reference in New Issue
Block a user