MCPcopy Create free account
hub / github.com/cinit/WSAPatch / defaultLogHandler

Function defaultLogHandler

WsaPatch.cpp:33–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
32
33void defaultLogHandler(Log::Level level, const WCHAR *tag, const WCHAR *msg) {
34 HANDLE handle = gConsoleOutput;
35 if (handle == nullptr || handle == INVALID_HANDLE_VALUE) {
36 return;
37 }
38 WCHAR buffer[1024] = {};
39 u64 now = currentTimeMillis();
40 const WCHAR *levelName = Log::levelName(level);
41 // MM-dd HH:mm:ss.SSS [level] tag: msg
42 int month = 0, day = 0, hour = 0, minute = 0, second = 0, millisecond = 0;
43 timeMillisToLocalCalendar(now, nullptr, &month, &day, &hour, &minute, &second, &millisecond);
44 StringCchPrintfW(buffer, _countof(buffer),
45 L"%02d-%02d %02d:%02d:%02d.%03d %c %s: %s\n",
46 month, day, hour, minute, second, millisecond,
47 WCHAR(*levelName), tag, msg);
48 DWORD written = 0;
49 WriteConsoleW(handle, buffer, static_cast<DWORD>(wcslen(buffer)), &written, nullptr);
50}
51
52using FuncRtlGetVersion = NTSYSAPI NTSTATUS(*)(PRTL_OSVERSIONINFOW lpVersionInformation);
53

Callers

nothing calls this directly

Calls 2

currentTimeMillisFunction · 0.85

Tested by

no test coverage detected