Rise
The Vieneo Province
Loading...
Searching...
No Matches
Logger.cpp
Go to the documentation of this file.
1#include "Logger.h"
4#include "Networking.h"
7#include <Psapi.h>
8#include <csignal>
9#include <cstdlib>
10#include <exception>
11#include <fstream>
12#include <vector>
13#include <mutex>
14#include <algorithm>
15
16namespace
17{
18 Logger* activeLogger = nullptr;
19 volatile LONG logSequence = 0;
20 constexpr DWORD pendingSignature = 0x31524352; // RCR1, local format (not a wire packet)
21 struct PendingCrash
22 {
23 DWORD signature = pendingSignature;
24 SErrorPacket report = {};
25 };
26
27 void DescribeUncleanExit(PendingCrash& pending, const char* traceName)
28 {
29 pending.report.level = Logger::Fatal;
30 std::snprintf(pending.report.entry, sizeof pending.report.entry,
31 "Unclean client exit; no exception captured (crash, forced stop or power loss possible); trace %s", traceName);
32 strcpy_s(pending.report.stackTrace,
33 "No crash-time stack was captured. The session trace contains the last logged activity.");
34 }
35
36 void WriteText(HANDLE file, const char* text) noexcept
37 {
38 DWORD written;
39 if (file != INVALID_HANDLE_VALUE)
40 WriteFile(file, text, static_cast<DWORD>(strlen(text)), &written, nullptr);
41 }
42
43 [[noreturn]] void StopAfterCrash(const char* reason, DWORD code)
44 {
45 if (activeLogger) activeLogger->RecordCrash(reason, code);
46 // No destructors, UI, or network access in a damaged process.
47 TerminateProcess(GetCurrentProcess(), code);
48 std::_Exit(static_cast<int>(code));
49 }
50 void __cdecl OnTerminate() { StopAfterCrash("std::terminate / unhandled C++ exception", 0xe0000001); }
51 void __cdecl OnAbort(int) { StopAfterCrash("CRT abort (SIGABRT)", 0xe0000002); }
52 void __cdecl OnPureCall() { StopAfterCrash("CRT pure virtual function call", 0xe0000003); }
53 void __cdecl OnInvalidParameter(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, uintptr_t)
54 {
55 StopAfterCrash("CRT invalid parameter", 0xc000000d);
56 }
57 LONG WINAPI OnUnhandledException(EXCEPTION_POINTERS* exception)
58 {
59 if (activeLogger)
60 activeLogger->RecordCrash("Unhandled Windows/C++ exception",
61 exception->ExceptionRecord->ExceptionCode, exception);
62 return EXCEPTION_EXECUTE_HANDLER;
63 }
64}
65
67{
69 HANDLE trace = INVALID_HANDLE_VALUE;
70 HANDLE pendingFile = INVALID_HANDLE_VALUE;
71 char pendingName[128] = {};
72 volatile LONG recorded = 0;
73 SRWLOCK breadcrumbLock = SRWLOCK_INIT;
75 PendingCrash pending;
76 char line[1024] = {};
77 LPTOP_LEVEL_EXCEPTION_FILTER previousFilter = nullptr;
78 std::terminate_handler previousTerminate = nullptr;
79 _invalid_parameter_handler previousInvalid = nullptr;
80 _purecall_handler previousPureCall = nullptr;
81 void (__cdecl* previousAbort)(int) = nullptr;
82 struct Upload { std::uint32_t receipt; std::string marker; };
83 std::vector<Upload> uploads;
84 std::mutex errorUploadMutex;
86};
87
88long __stdcall Logger::HandleNativeException(EXCEPTION_POINTERS* exception)
89{
90 const DWORD code = exception->ExceptionRecord->ExceptionCode;
91 // Leave ordinary C++ exceptions and debugger events to their normal handlers.
92 if (code == 0xe06d7363 || code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP)
93 return EXCEPTION_CONTINUE_SEARCH;
94 if (activeLogger) activeLogger->RecordCrash("Windows exception", code, exception);
95 return EXCEPTION_EXECUTE_HANDLER;
96}
97
98void Logger::RecordCrash(const char* reason, unsigned long code, EXCEPTION_POINTERS* exception) noexcept
99{
100 if (InterlockedCompareExchange(&crash->recorded, 1, 0) != 0) return;
101 // All storage and handles already exist. Do not call Log: it allocates and
102 // may send packets. Never wait on a lock held by the faulting/game thread.
103 const bool haveBreadcrumbs = TryAcquireSRWLockShared(&crash->breadcrumbLock) != FALSE;
104 if (haveBreadcrumbs)
105 {
106 crash->snapshot = breadcrumbs;
107 ReleaseSRWLockShared(&crash->breadcrumbLock);
108 }
109 crash->pending.report.level = Fatal;
110 std::snprintf(crash->pending.report.entry, sizeof crash->pending.report.entry,
111 "%.140s (0x%08lx), trace %s", reason ? reason : "Fatal error", code, fileName);
112 if (haveBreadcrumbs) crash->snapshot.FormatPacket(crash->pending.report.stackTrace);
113 else strcpy_s(crash->pending.report.stackTrace, "Breadcrumb snapshot unavailable: recorder busy");
114 // Stable ID links this existing server/email report to the independent dump upload.
115 const size_t stackUsed = (std::min)(strlen(crash->pending.report.stackTrace), sizeof crash->pending.report.stackTrace - 72);
116 std::snprintf(crash->pending.report.stackTrace + stackUsed,
117 sizeof crash->pending.report.stackTrace - stackUsed, "\nNative dump ID: %ls", crash->dump.Id());
118
119 SYSTEMTIME st;
120 GetLocalTime(&st);
121 std::snprintf(crash->line, sizeof crash->line,
122 "\r\n%02u:%02u:%02u.%03u FATAL: %.700s (0x%08lx), thread %lu\r\n",
123 st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
124 reason ? reason : "Fatal error", code, GetCurrentThreadId());
125 WriteText(crash->trace, crash->line);
126 DWORD written;
127 // Replace the startup record rather than appending a second record.
128 SetFilePointer(crash->pendingFile, 0, nullptr, FILE_BEGIN);
129 WriteFile(crash->pendingFile, &crash->pending, sizeof crash->pending, &written, nullptr);
130 FlushFileBuffers(crash->pendingFile);
131 FlushFileBuffers(crash->trace);
132 // Capture before optional module/driver queries: those can enter loader locks.
133 const DWORD dumpResult = crash->dump.Record(reason, code, exception);
134 std::snprintf(crash->line, sizeof crash->line,
135 "Native dump ID: %ls; helper capture result: 0x%08lx (0=locally saved)\r\n", crash->dump.Id(), dumpResult);
136 WriteText(crash->trace, crash->line);
137 FlushFileBuffers(crash->trace);
138
139 if (exception)
140 {
141 const EXCEPTION_RECORD& record = *exception->ExceptionRecord;
142 std::snprintf(crash->line, sizeof crash->line, "Exception address: %p\r\n", record.ExceptionAddress);
143 WriteText(crash->trace, crash->line);
144 if ((code == EXCEPTION_ACCESS_VIOLATION || code == EXCEPTION_IN_PAGE_ERROR) && record.NumberParameters >= 2)
145 {
146 std::snprintf(crash->line, sizeof crash->line, "Memory operation: %llu (0=read, 1=write, 8=execute), address: %p\r\n",
147 static_cast<unsigned long long>(record.ExceptionInformation[0]),
148 reinterpret_cast<void*>(record.ExceptionInformation[1]));
149 WriteText(crash->trace, crash->line);
150 }
151#if defined(_M_IX86)
152 const CONTEXT& context = *exception->ContextRecord;
153 std::snprintf(crash->line, sizeof crash->line,
154 "Registers: EIP=%08lx ESP=%08lx EBP=%08lx EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx ESI=%08lx EDI=%08lx\r\n",
155 context.Eip, context.Esp, context.Ebp, context.Eax, context.Ebx, context.Ecx, context.Edx, context.Esi, context.Edi);
156 WriteText(crash->trace, crash->line);
157#endif
158 }
159 WriteText(crash->trace, "Simulated call stack (recent breadcrumbs, newest first; may span threads):\r\n");
160 if (!haveBreadcrumbs) WriteText(crash->trace, " --> unavailable: breadcrumb recorder busy\r\n");
161 for (std::size_t i = 0; i < crash->snapshot.Count(); ++i)
162 {
163 std::snprintf(crash->line, sizeof crash->line, " --> %s\r\n", crash->snapshot.Recent(i));
164 WriteText(crash->trace, crash->line);
165 }
166 WriteText(crash->trace, "Crash report saved locally; upload will be retried on the next connection.\r\n");
167 FlushFileBuffers(crash->trace);
168 // The essential record is already durable. These OS queries use stack storage
169 // and remain useful when the failing allocation was in Direct3D or the heap.
170 MEMORYSTATUSEX memory = {};
171 memory.dwLength = sizeof memory;
172 if (GlobalMemoryStatusEx(&memory))
173 {
174 std::snprintf(crash->line, sizeof crash->line,
175 "Memory bytes: virtual total=%llu available=%llu; physical available=%llu; commit available=%llu\r\n",
176 memory.ullTotalVirtual, memory.ullAvailVirtual, memory.ullAvailPhys, memory.ullAvailPageFile);
177 WriteText(crash->trace, crash->line);
178 }
179 PROCESS_MEMORY_COUNTERS_EX processMemory = {};
180 if (GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&processMemory), sizeof processMemory))
181 {
182 std::snprintf(crash->line, sizeof crash->line,
183 "Process memory bytes: private=%llu workingSet=%llu peakWorkingSet=%llu\r\n",
184 static_cast<unsigned long long>(processMemory.PrivateUsage),
185 static_cast<unsigned long long>(processMemory.WorkingSetSize),
186 static_cast<unsigned long long>(processMemory.PeakWorkingSetSize));
187 WriteText(crash->trace, crash->line);
188 }
189 FlushFileBuffers(crash->trace);
190 // Optional module identification comes after the essential record is durable.
191 if (exception)
192 {
193 HMODULE module = nullptr;
194 if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
195 reinterpret_cast<LPCSTR>(exception->ExceptionRecord->ExceptionAddress), &module))
196 {
197 char modulePath[MAX_PATH] = {};
198 GetModuleFileNameA(module, modulePath, MAX_PATH);
199 std::snprintf(crash->line, sizeof crash->line, "Fault module: %s base=%p RVA=0x%llx\r\n", modulePath, module,
200 static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(exception->ExceptionRecord->ExceptionAddress) - reinterpret_cast<uintptr_t>(module)));
201 WriteText(crash->trace, crash->line);
202 FlushFileBuffers(crash->trace);
203 }
204 }
205}
206
207void Logger::SendTraceFile(bool waitForDelivery) const
208{
209 if (QueueTraceFile(false) && waitForDelivery) networking->Flush();
210}
211
212std::uint32_t Logger::QueueTraceFile(bool requestReceipt) const
213{
214 if (!networking) return 0;
215 std::ifstream file(fileName, std::ios::binary);
216 if (!file) return 0;
217 const std::string contents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
218 return networking->SendTraceFile(contents.c_str(), requestReceipt);
219}
220
222{
223 if (!networking) return;
224 {
225 std::lock_guard<std::mutex> lock(crash->errorUploadMutex);
226 crash->errorUploadBudget.ResetConnection();
227 }
228 crash->uploads.clear(); // A new connection invalidates outstanding receipts.
229 WIN32_FIND_DATAA found;
230 HANDLE search = FindFirstFileA("trace_*.log.pending", &found);
231 if (search == INVALID_HANDLE_VALUE) return;
232 do
233 {
234 if (strcmp(found.cFileName, crash->pendingName) == 0 ||
235 found.nFileSizeHigh != 0 ||
236 (found.nFileSizeLow != 0 && found.nFileSizeLow != sizeof(PendingCrash))) continue;
237 // Exclusive access skips reports belonging to another running client.
238 HANDLE marker = CreateFileA(found.cFileName, GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr);
239 if (marker == INVALID_HANDLE_VALUE) continue;
240 PendingCrash saved;
241 DWORD bytes = 0;
242 const std::string traceName(found.cFileName, strlen(found.cFileName) - strlen(".pending"));
243 // Older builds left an empty marker when termination bypassed every handler.
244 const bool legacyUncleanExit = found.nFileSizeLow == 0;
245 if (legacyUncleanExit) DescribeUncleanExit(saved, traceName.c_str());
246 const bool valid = legacyUncleanExit || (ReadFile(marker, &saved, sizeof saved, &bytes, nullptr) &&
247 bytes == sizeof saved && saved.signature == pendingSignature && saved.report.level == Fatal);
248 CloseHandle(marker);
249 if (!valid) continue;
250 saved.report.entry[sizeof saved.report.entry - 1] = 0;
251 saved.report.stackTrace[sizeof saved.report.stackTrace - 1] = 0;
252 std::ifstream file(traceName, std::ios::binary);
253 if (!file) continue;
254 const std::string contents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
255 if (!networking->SendErrorReport(&saved.report)) break;
256 const std::uint32_t receipt = networking->SendTraceFile(contents.c_str(), true);
257 if (!receipt) break;
258 crash->uploads.push_back({ receipt, found.cFileName });
259 Log(("Queued saved crash report: " + traceName).c_str());
260 // Stay below the server's per-session error limit; retain the rest for later.
261 } while (crash->uploads.size() < 8 && FindNextFileA(search, &found));
262 FindClose(search);
263}
264
265void Logger::ConfirmTraceDelivery(std::uint32_t receipt)
266{
267 {
268 std::lock_guard<std::mutex> lock(crash->errorUploadMutex);
269 crash->errorUploadBudget.Confirm(receipt);
270 }
271 for (auto it = crash->uploads.begin(); it != crash->uploads.end(); ++it)
272 {
273 if (it->receipt != receipt) continue;
274 // This ACK confirms transport receipt, not a server database/disk commit.
275 if (DeleteFileA(it->marker.c_str()))
276 Log(("Server transport acknowledged saved crash trace: " + it->marker).c_str());
277 else Log("Could not remove acknowledged crash marker; retained for retry", Warn);
278 crash->uploads.erase(it);
279 break;
280 }
281}
282
283void Logger::Log(const char* msg, Level level, int errorCode)
284{
285 if (!msg) msg = "(null log message)";
286 if (level == Fatal) RecordCrash(msg, static_cast<DWORD>(errorCode));
287 lastError = msg;
288 lastLevel = level;
289 lastErrorCode = errorCode;
290 SYSTEMTIME st;
291 GetLocalTime(&st);
292 const char* prefix = level == Warn ? "Warning: " : level == Debug ? "DEBUG: " :
293 level == Error ? "ERROR: " : level == Fatal ? "FATAL: " : "";
294 char heading[64];
295 std::snprintf(heading, sizeof heading, "%02u:%02u:%02u.%03u %s",
296 st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, prefix);
297 std::string line = heading;
298 line += msg;
299 char suffix[128] = {};
300 if (errorCode != 0)
301 {
303 {
304 auto* host = Rendering::ClientHost();
305 // The device query uses no immediate-context operations and runs before
306 // recovery can replace the failed device. RecordCrash never calls here.
307 auto* device = host ? host->Device().Device() : nullptr;
308 const auto detail = Rendering::DeviceFailureDiagnostics11(errorCode, device);
309 strncpy_s(suffix, detail.c_str(), _TRUNCATE);
310 }
311 else std::snprintf(suffix, sizeof suffix, " (0x%x - %ls)", errorCode, Rendering::ErrorString(errorCode));
312 line += suffix;
313 }
314 line += "\r\n";
315 if (errorCode == E_OUTOFMEMORY || Rendering::IsDeviceRemovalError11(errorCode))
316 {
317 auto* host = Rendering::ClientHost();
318 line += heading;
319 line += Rendering::MemoryDiagnostics11(host ? host->Device().Device() : nullptr);
320 line += "\r\n";
321 }
322 WriteText(crash->trace, line.c_str());
323 if (networking && (level == Fatal || level == Error || level == Debug))
324 {
325 std::unique_lock<std::mutex> uploadLock(crash->errorUploadMutex, std::defer_lock);
326 if (level == Error)
327 {
328 // Every occurrence is still written locally above. Do not read/copy the
329 // trace again while a prior upload is queued or within the cooldown.
330 if (!uploadLock.try_lock() || !crash->errorUploadBudget.CanSend(GetTickCount64())) return;
331 }
332 SErrorPacket errorPacket = {};
333 errorPacket.level = level;
334 std::snprintf(errorPacket.entry, sizeof errorPacket.entry, "%.190s%.64s", msg, suffix);
335 AcquireSRWLockShared(&crash->breadcrumbLock);
337 ReleaseSRWLockShared(&crash->breadcrumbLock);
338 if (networking->SendErrorReport(&errorPacket) && level == Error)
339 crash->errorUploadBudget.Sent(GetTickCount64(), QueueTraceFile(true));
340 }
341 if (level == Fatal)
342 {
345 {
347 SetCursor(LoadCursor(nullptr, IDC_ARROW));
348 }
349 MessageBoxA(Rendering::ClientWindow(), msg, "Fatal Exception", MB_ICONERROR | MB_OK);
351 exit(errorCode != 0 ? errorCode : EXIT_FAILURE);
352 }
353}
354
355void Logger::AddToCallStack(const char* msg)
356{
357 AcquireSRWLockExclusive(&crash->breadcrumbLock);
358 breadcrumbs.Add(msg);
359 ReleaseSRWLockExclusive(&crash->breadcrumbLock);
360}
361
362void Logger::SetNetworkingPointer(Networking* prmNetworking) { networking = prmNetworking; }
363
364void Logger::RemoveOldFiles(const wchar_t* searchkey, int maxDays)
365{
366 WIN32_FIND_DATAW fd;
367 HANDLE h = FindFirstFileW(searchkey, &fd);
368 if (h == INVALID_HANDLE_VALUE) return;
369 FILETIME ftNow;
370 GetSystemTimeAsFileTime(&ftNow);
371 ULARGE_INTEGER current;
372 current.HighPart = ftNow.dwHighDateTime;
373 current.LowPart = ftNow.dwLowDateTime;
374 do
375 {
376 // Unsent reports survive normal trace retention.
377 const std::wstring marker = std::wstring(fd.cFileName) + L".pending";
378 WIN32_FILE_ATTRIBUTE_DATA pending;
379 if (GetFileAttributesExW(marker.c_str(), GetFileExInfoStandard, &pending)) continue;
380 ULARGE_INTEGER created;
381 created.HighPart = fd.ftCreationTime.dwHighDateTime;
382 created.LowPart = fd.ftCreationTime.dwLowDateTime;
383 if (current.QuadPart > created.QuadPart &&
384 (current.QuadPart - created.QuadPart) / 864000000000ULL > static_cast<ULONGLONG>(maxDays))
385 {
386 if (DeleteFileW(fd.cFileName)) DeleteFileW(marker.c_str());
387 }
388 } while (FindNextFileW(h, &fd));
389 FindClose(h);
390}
391
392Logger::Logger() : crash(std::make_unique<CrashState>())
393{
394 RemoveOldFiles(L"trace_*.log", 7);
395 SYSTEMTIME st;
396 GetLocalTime(&st);
397 std::snprintf(fileName, sizeof fileName, "trace_%04u-%02u-%02u-%02u%02u%02u-%03u-%lu-%ld.log",
398 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
399 GetCurrentProcessId(), InterlockedIncrement(&logSequence));
400 crash->trace = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
401 if (crash->trace == INVALID_HANDLE_VALUE)
402 {
403 MessageBoxA(nullptr, "Could not open logfile for writing!", "Fatal Exception", MB_ICONERROR | MB_OK);
404 exit(EXIT_FAILURE);
405 }
406 std::snprintf(crash->pendingName, sizeof crash->pendingName, "%s.pending", fileName);
407 crash->pendingFile = CreateFileA(crash->pendingName, GENERIC_WRITE, FILE_SHARE_READ, nullptr,
408 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
409 // Establish evidence while the process is healthy. Fast-fail and an external
410 // kill can bypass all handlers; a normal destructor removes this record.
411 DescribeUncleanExit(crash->pending, fileName);
412 DWORD written = 0;
413 const bool pendingSaved = WriteFile(crash->pendingFile, &crash->pending, sizeof crash->pending,
414 &written, nullptr) && written == sizeof crash->pending && FlushFileBuffers(crash->pendingFile);
415 activeLogger = this;
416 crash->previousFilter = SetUnhandledExceptionFilter(OnUnhandledException);
417 crash->previousTerminate = std::set_terminate(OnTerminate);
418 crash->previousInvalid = _set_invalid_parameter_handler(OnInvalidParameter);
419 crash->previousPureCall = _set_purecall_handler(OnPureCall);
420 crash->previousAbort = std::signal(SIGABRT, OnAbort);
421 // Reserve filter stack space on the main thread.
422 ULONG stackGuarantee = 32768;
423 SetThreadStackGuarantee(&stackGuarantee);
424 const DWORD dumpStartup = crash->dump.Start(fileName);
425 Log((std::string("Logger::ctor Opened logfile \"") + fileName + "\"").c_str());
426 Log("Crash diagnostics enabled; build " __DATE__ " " __TIME__);
427 char dumpStatus[4096];
428 if (crash->dump.UpdateError())
429 {
430 std::snprintf(dumpStatus, sizeof dumpStatus,
431 "Native crash helper update deferred: 0x%08lx at InstallStagedHelper; installed helper=%ls; pending CrashHandler1.exe retained",
432 crash->dump.UpdateError(), crash->dump.HelperPath());
433 Log(dumpStatus, Warn);
434 }
435 std::snprintf(dumpStatus, sizeof dumpStatus,
436 "Native crash helper startup: 0x%08lx; stage=%s; dump ID %ls; helper=%ls; local queue=%ls",
437 dumpStartup, crash->dump.StartupStage(), crash->dump.Id(), crash->dump.HelperPath(), crash->dump.Directory());
438 Log(dumpStatus, dumpStartup ? Warn : Info);
439 char executable[MAX_PATH] = {};
440 GetModuleFileNameA(nullptr, executable, MAX_PATH);
441 Log(executable);
442 if (crash->pendingFile == INVALID_HANDLE_VALUE)
443 Log("Could not create crash retry marker; local trace remains available", Warn);
444 else if (!pendingSaved)
445 Log("Could not persist startup crash retry record; local trace remains available", Warn);
446}
447
449{
450 Log("Logger::dtor Closing logfile...");
451 SetUnhandledExceptionFilter(crash->previousFilter);
452 std::set_terminate(crash->previousTerminate);
453 _set_invalid_parameter_handler(crash->previousInvalid);
454 _set_purecall_handler(crash->previousPureCall);
455 std::signal(SIGABRT, crash->previousAbort);
456 activeLogger = nullptr;
457 CloseHandle(crash->pendingFile);
458 CloseHandle(crash->trace);
459 if (!crash->recorded) DeleteFileA(crash->pendingName);
460}
SCRIPT_CONTROL SCRIPT_STATE const void int
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
void Add(const char *message)
void FormatPacket(char(&destination)[Size]) const
Level lastLevel
Definition Logger.h:44
std::string lastError
Definition Logger.h:43
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
std::uint32_t QueueTraceFile(bool requestReceipt) const
Definition Logger.cpp:212
Networking * networking
Definition Logger.h:14
static void RemoveOldFiles(const wchar_t *searchkey, int maxDays)
Definition Logger.cpp:364
void SetNetworkingPointer(Networking *prmNetworking)
Definition Logger.cpp:362
static long __stdcall HandleNativeException(struct _EXCEPTION_POINTERS *exception)
Definition Logger.cpp:88
void RecordCrash(const char *reason, unsigned long code=0, struct _EXCEPTION_POINTERS *exception=nullptr) noexcept
Definition Logger.cpp:98
void SendPendingCrashReports()
Definition Logger.cpp:221
int lastErrorCode
Definition Logger.h:45
void SendTraceFile(bool waitForDelivery=true) const
Definition Logger.cpp:207
CrashBreadcrumbs breadcrumbs
Definition Logger.h:16
std::unique_ptr< CrashState > crash
Definition Logger.h:13
void ConfirmTraceDelivery(std::uint32_t receipt)
Definition Logger.cpp:265
Logger()
Definition Logger.cpp:392
~Logger()
Definition Logger.cpp:448
Level
Definition Logger.h:23
@ Debug
Definition Logger.h:27
@ Info
Definition Logger.h:25
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
char fileName[99]
Definition Logger.h:15
std::uint32_t SendTraceFile(const char *fileContents, bool requestReceipt=false) const
bool Flush() const
bool SendErrorReport(SErrorPacket *pData) const
bool IsDeviceRemovalError11(HRESULT result)
HWND ClientWindow()
std::string MemoryDiagnostics11(ID3D11Device *device)
Window11 * ClientHost()
std::string DeviceFailureDiagnostics11(HRESULT operation, ID3D11Device *device)
const wchar_t * ErrorString(HRESULT code)
HRESULT ClientToggleFullscreen()
bool ClientWindowed()
#define __cdecl
std::uint32_t receipt
Definition Logger.cpp:82
std::vector< Upload > uploads
Definition Logger.cpp:83
CrashReporting::Capture dump
Definition Logger.cpp:68
std::mutex errorUploadMutex
Definition Logger.cpp:84
void(__cdecl *previousAbort)(int)
volatile LONG recorded
Definition Logger.cpp:72
std::terminate_handler previousTerminate
Definition Logger.cpp:78
char line[1024]
Definition Logger.cpp:76
_invalid_parameter_handler previousInvalid
Definition Logger.cpp:79
PendingCrash pending
Definition Logger.cpp:75
DiagnosticUploadBudget errorUploadBudget
Definition Logger.cpp:85
_purecall_handler previousPureCall
Definition Logger.cpp:80
CrashBreadcrumbs snapshot
Definition Logger.cpp:74
char pendingName[128]
Definition Logger.cpp:71
SRWLOCK breadcrumbLock
Definition Logger.cpp:73
LPTOP_LEVEL_EXCEPTION_FILTER previousFilter
Definition Logger.cpp:77
char entry[256]
char stackTrace[256]