aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/logging.cpp
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-03-27 10:54:09 +0200
committerGitHub <noreply@github.com>2022-03-27 10:54:09 +0200
commitf1a8ce9337ce84f25fc1a78458f43377c7b36f4d (patch)
treebb5ea746c277f6b6c720deac8e6dadcd682440f7 /NorthstarDedicatedTest/logging.cpp
parentb5405b462656b83a37bf1eb41b049b0913980a13 (diff)
parent379cbc8bc251307777a14b901e5617e834398485 (diff)
downloadNorthstarLauncher-f1a8ce9337ce84f25fc1a78458f43377c7b36f4d.tar.gz
NorthstarLauncher-f1a8ce9337ce84f25fc1a78458f43377c7b36f4d.zip
Merge branch 'main' into NetCon
Diffstat (limited to 'NorthstarDedicatedTest/logging.cpp')
-rw-r--r--NorthstarDedicatedTest/logging.cpp66
1 files changed, 45 insertions, 21 deletions
diff --git a/NorthstarDedicatedTest/logging.cpp b/NorthstarDedicatedTest/logging.cpp
index b9922ba5..8508e61c 100644
--- a/NorthstarDedicatedTest/logging.cpp
+++ b/NorthstarDedicatedTest/logging.cpp
@@ -54,74 +54,77 @@ long __stdcall ExceptionFilter(EXCEPTION_POINTERS* exceptionInfo)
return EXCEPTION_CONTINUE_SEARCH;
std::stringstream exceptionCause;
+ exceptionCause << "Cause: ";
switch (exceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
case EXCEPTION_IN_PAGE_ERROR:
{
- exceptionCause << "Cause: Access Violation" << std::endl;
+ exceptionCause << "Access Violation" << std::endl;
auto exceptionInfo0 = exceptionInfo->ExceptionRecord->ExceptionInformation[0];
auto exceptionInfo1 = exceptionInfo->ExceptionRecord->ExceptionInformation[1];
if (!exceptionInfo0)
- exceptionCause << "Attempted to read from: 0x" << std::setw(8) << std::setfill('0') << std::hex << exceptionInfo1;
+ exceptionCause << "Attempted to read from: 0x" << (void*)exceptionInfo1;
else if (exceptionInfo0 == 1)
- exceptionCause << "Attempted to write to: 0x" << std::setw(8) << std::setfill('0') << std::hex << exceptionInfo1;
+ exceptionCause << "Attempted to write to: 0x" << (void*)exceptionInfo1;
else if (exceptionInfo0 == 8)
- exceptionCause << "Data Execution Prevention (DEP) at: 0x" << std::setw(8) << std::setfill('0') << std::hex
+ exceptionCause << "Data Execution Prevention (DEP) at: 0x" << (void*)std::hex
<< exceptionInfo1;
else
- exceptionCause << "Unknown access violation at: 0x" << std::setw(8) << std::setfill('0') << std::hex << exceptionInfo1;
+ exceptionCause << "Unknown access violation at: 0x" << (void*)exceptionInfo1;
break;
}
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
- exceptionCause << "Cause: Array bounds exceeded";
+ exceptionCause << "Array bounds exceeded";
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
- exceptionCause << "Cause: Datatype misalignment";
+ exceptionCause << "Datatype misalignment";
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
- exceptionCause << "Cause: Denormal operand";
+ exceptionCause << "Denormal operand";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ exceptionCause << "Divide by zero (float)";
+ break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
- exceptionCause << "Cause: Divide by zero";
+ exceptionCause << "Divide by zero (int)";
break;
case EXCEPTION_FLT_INEXACT_RESULT:
- exceptionCause << "Cause: Inexact result";
+ exceptionCause << "Inexact result";
break;
case EXCEPTION_FLT_INVALID_OPERATION:
- exceptionCause << "Cause: invalid operation";
+ exceptionCause << "Invalid operation";
break;
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_INT_OVERFLOW:
- exceptionCause << "Cause: Numeric overflow";
+ exceptionCause << "Numeric overflow";
break;
case EXCEPTION_FLT_UNDERFLOW:
- exceptionCause << "Cause: Numeric underflow";
+ exceptionCause << "Numeric underflow";
break;
case EXCEPTION_FLT_STACK_CHECK:
- exceptionCause << "Cause: Stack check";
+ exceptionCause << "Stack check";
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
- exceptionCause << "Cause: Illegal instruction";
+ exceptionCause << "Illegal instruction";
break;
case EXCEPTION_INVALID_DISPOSITION:
- exceptionCause << "Cause: Invalid disposition";
+ exceptionCause << "Invalid disposition";
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
- exceptionCause << "Cause: Noncontinuable exception";
+ exceptionCause << "Noncontinuable exception";
break;
case EXCEPTION_PRIV_INSTRUCTION:
- exceptionCause << "Cause: Priv instruction";
+ exceptionCause << "Priviledged instruction";
break;
case EXCEPTION_STACK_OVERFLOW:
- exceptionCause << "Cause: Stack overflow";
+ exceptionCause << "Stack overflow";
break;
default:
- exceptionCause << "Cause: Unknown";
+ exceptionCause << "Unknown";
break;
}
@@ -208,14 +211,33 @@ long __stdcall ExceptionFilter(EXCEPTION_POINTERS* exceptionInfo)
return EXCEPTION_EXECUTE_HANDLER;
}
+HANDLE hExceptionFilter;
+
+BOOL WINAPI ConsoleHandlerRoutine(DWORD eventCode)
+{
+ switch (eventCode)
+ {
+ case CTRL_CLOSE_EVENT:
+ // User closed console, shut everything down
+ spdlog::info("Exiting due to console close...");
+ RemoveVectoredExceptionHandler(hExceptionFilter);
+ exit(EXIT_SUCCESS);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void InitialiseLogging()
{
- AddVectoredExceptionHandler(TRUE, ExceptionFilter);
+ hExceptionFilter = AddVectoredExceptionHandler(TRUE, ExceptionFilter);
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
spdlog::default_logger()->set_pattern("[%H:%M:%S] [%l] %v");
+
+ SetConsoleCtrlHandler(ConsoleHandlerRoutine, true);
}
ConVar* Cvar_spewlog_enable;
@@ -223,10 +245,12 @@ ConVar* Cvar_spewlog_enable;
enum SpewType_t
{
SPEW_MESSAGE = 0,
+
SPEW_WARNING,
SPEW_ASSERT,
SPEW_ERROR,
SPEW_LOG,
+
SPEW_TYPE_COUNT
};