diff --git a/core/src/logger.cpp b/core/src/logger.cpp index 16620cc..db9032e 100644 --- a/core/src/logger.cpp +++ b/core/src/logger.cpp @@ -35,10 +35,10 @@ void Logger::log(std::string message, Logger::LogLevel logLevel) { std::string formattedLogLine = std::format("[{:%Y-%m-%d %X}] [{}] {}", now, logLevelStr, message); - printf("%s\n", formattedLogLine.c_str()); logStream << formattedLogLine << std::endl; + printf("FATAL ERROR: %s\n", message.c_str()); if (logLevel == Logger::LogLevel::FATAL_ERROR) { - displayErrorMessage(formattedLogLine); + displayErrorMessage(message); } -} \ No newline at end of file +} diff --git a/core/src/panic.cpp b/core/src/panic.cpp index 61fe5bb..e0b1f9d 100644 --- a/core/src/panic.cpp +++ b/core/src/panic.cpp @@ -15,7 +15,7 @@ void panic() { abort(); trySafeAbort = true; -#ifndef NDEBUG +#ifdef NDEBUG displayErrorMessage(std::string("A fatal error has occurred and Openblocks had to shut down.\n\ The currently open document will be attempted to be saved, and logs will be written to " + getProgramLogsDir())); #endif @@ -26,4 +26,4 @@ The currently open document will be attempted to be saved, and logs will be writ // TODO: Autosave document abort(); -} \ No newline at end of file +} diff --git a/core/src/platform.cpp b/core/src/platform.cpp index e274bea..2438828 100644 --- a/core/src/platform.cpp +++ b/core/src/platform.cpp @@ -42,15 +42,15 @@ std::string getProgramDataDir() { CHAR localAppData[MAX_PATH]; int status = SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, localAppData); if (status != 0) { - printErrorMessage("Failed to find local appdata folder"); + displayErrorMessage("Failed to find local appdata folder"); panic(); } - return localAppData + "/openblocks"; + return std::string(localAppData) + "/openblocks"; } void displayErrorMessage(std::string message) { fprintf(stderr, "%s\n", message.c_str()); - MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK); + MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK | MB_ICONERROR); } #endif // WIN32 @@ -65,4 +65,4 @@ void initProgramDataDir() { void initProgramLogsDir() { std::filesystem::create_directories(getProgramLogsDir()); -} \ No newline at end of file +}