From d524bf26da51feb6940bf80aa1705da443d4334c Mon Sep 17 00:00:00 2001 From: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:15:04 +0000 Subject: [PATCH] convert newer logs to refactored logging --- NorthstarDLL/client/debugoverlay.cpp | 2 +- NorthstarDLL/logging/crashhandler.cpp | 56 +++++++------- .../mods/autodownload/moddownloader.cpp | 76 +++++++++---------- NorthstarDLL/mods/modmanager.cpp | 2 +- NorthstarDLL/mods/modsavefiles.cpp | 23 +++--- NorthstarDLL/squirrel/squirrelclasstypes.h | 2 +- NorthstarDLL/util/printcommands.cpp | 6 +- 7 files changed, 83 insertions(+), 84 deletions(-) diff --git a/NorthstarDLL/client/debugoverlay.cpp b/NorthstarDLL/client/debugoverlay.cpp index e231054d4..8a55c3de6 100644 --- a/NorthstarDLL/client/debugoverlay.cpp +++ b/NorthstarDLL/client/debugoverlay.cpp @@ -244,7 +244,7 @@ void, __fastcall, (OverlayBase_t * pOverlay)) break; default: { - spdlog::warn("Unimplemented overlay type {}", pOverlay->m_Type); + Warning(eLog::ENGINE, "Unimplemented overlay type %i\n", pOverlay->m_Type); } break; } diff --git a/NorthstarDLL/logging/crashhandler.cpp b/NorthstarDLL/logging/crashhandler.cpp index 5dec315ab..aeaef1d0a 100644 --- a/NorthstarDLL/logging/crashhandler.cpp +++ b/NorthstarDLL/logging/crashhandler.cpp @@ -84,7 +84,7 @@ BOOL WINAPI ConsoleCtrlRoutine(DWORD dwCtrlType) switch (dwCtrlType) { case CTRL_CLOSE_EVENT: - spdlog::info("Exiting due to console close..."); + DevMsg(eLog::NS, "Exiting due to console close...\n"); delete g_pCrashHandler; g_pCrashHandler = nullptr; std::exit(EXIT_SUCCESS); @@ -310,15 +310,15 @@ void CCrashHandler::ShowPopUpMessage() //----------------------------------------------------------------------------- void CCrashHandler::FormatException() { - spdlog::error("-------------------------------------------"); - spdlog::error("Northstar has crashed!"); - spdlog::error("\tVersion: {}", version); + Error(eLog::NS, NO_ERROR, "-------------------------------------------\n"); + Error(eLog::NS, NO_ERROR, "Northstar has crashed!\n"); + Error(eLog::NS, NO_ERROR, "\tVersion: %s\n", version); if (!m_svError.empty()) { - spdlog::info("\tEncountered an error when gathering crash information!"); - spdlog::info("\tWinApi Error: {}", m_svError.c_str()); + DevMsg(eLog::NS, "\tEncountered an error when gathering crash information!\n"); + DevMsg(eLog::NS, "\tWinApi Error: %s\n", m_svError.c_str()); } - spdlog::error("\t{}", GetExceptionString()); + Error(eLog::NS, NO_ERROR, "\t%s", GetExceptionString()); DWORD dwExceptionCode = m_pExceptionInfos->ExceptionRecord->ExceptionCode; if (dwExceptionCode == EXCEPTION_ACCESS_VIOLATION || dwExceptionCode == EXCEPTION_IN_PAGE_ERROR) @@ -327,16 +327,16 @@ void CCrashHandler::FormatException() ULONG_PTR uExceptionInfo1 = m_pExceptionInfos->ExceptionRecord->ExceptionInformation[1]; if (!uExceptionInfo0) - spdlog::error("\tAttempted to read from: {:#x}", uExceptionInfo1); + Error(eLog::NS, NO_ERROR, "\tAttempted to read from: %p\n", uExceptionInfo1); else if (uExceptionInfo0 == 1) - spdlog::error("\tAttempted to write to: {:#x}", uExceptionInfo1); + Error(eLog::NS, NO_ERROR, "\tAttempted to write to: %p\n", uExceptionInfo1); else if (uExceptionInfo0 == 8) - spdlog::error("\tData Execution Prevention (DEP) at: {:#x}", uExceptionInfo1); + Error(eLog::NS, NO_ERROR, "\tData Execution Prevention (DEP) at: %p\n", uExceptionInfo1); else - spdlog::error("\tUnknown access violation at: {:#x}", uExceptionInfo1); + Error(eLog::NS, NO_ERROR, "\tUnknown access violation at: %p\n", uExceptionInfo1); } - spdlog::error("\tAt: {} + {}", m_svCrashedModule, m_svCrashedOffset); + Error(eLog::NS, NO_ERROR, "\tAt: %s + %s\n", m_svCrashedModule.c_str(), m_svCrashedOffset.c_str()); } //----------------------------------------------------------------------------- @@ -344,7 +344,7 @@ void CCrashHandler::FormatException() //----------------------------------------------------------------------------- void CCrashHandler::FormatCallstack() { - spdlog::error("Callstack:"); + Error(eLog::NS, NO_ERROR, "Callstack:\n"); PVOID pFrames[CRASHHANDLER_MAX_FRAMES]; @@ -394,7 +394,7 @@ void CCrashHandler::FormatCallstack() } // Log module + offset - spdlog::error("\t{} + {:#x}", pszModuleFileName, reinterpret_cast(pCrashOffset)); + Error(eLog::NS, NO_ERROR, "\t%s + %s", pszModuleFileName, svCrashOffset.c_str()); } } @@ -403,7 +403,7 @@ void CCrashHandler::FormatCallstack() //----------------------------------------------------------------------------- void CCrashHandler::FormatFlags(const CHAR* pszRegister, DWORD nValue) { - spdlog::error("\t{}: {:#b}", pszRegister, nValue); + Error(eLog::NS, NO_ERROR, "\t%s: 0x%x\n", pszRegister, nValue); } //----------------------------------------------------------------------------- @@ -411,7 +411,7 @@ void CCrashHandler::FormatFlags(const CHAR* pszRegister, DWORD nValue) //----------------------------------------------------------------------------- void CCrashHandler::FormatIntReg(const CHAR* pszRegister, DWORD64 nValue) { - spdlog::error("\t{}: {:#x}", pszRegister, nValue); + Error(eLog::NS, NO_ERROR, "\t%s: 0x%x\n", pszRegister, nValue); } //----------------------------------------------------------------------------- @@ -425,8 +425,8 @@ void CCrashHandler::FormatFloatReg(const CHAR* pszRegister, M128A nValue) static_cast(nValue.High & UINT_MAX), static_cast(nValue.High >> 32)}; - spdlog::error( - "\t{}: [ {:G}, {:G}, {:G}, {:G} ]; [ {:#x}, {:#x}, {:#x}, {:#x} ]", + Error(eLog::NS, NO_ERROR, + "\t%s: [ %f, %f, %f, %f ]; [ 0x%x, 0x%x, 0x%x, 0x%x ]\n", pszRegister, static_cast(nVec[0]), static_cast(nVec[1]), @@ -443,7 +443,7 @@ void CCrashHandler::FormatFloatReg(const CHAR* pszRegister, M128A nValue) //----------------------------------------------------------------------------- void CCrashHandler::FormatRegisters() { - spdlog::error("Registers:"); + Error(eLog::NS, NO_ERROR, "Registers:"); PCONTEXT pContext = m_pExceptionInfos->ContextRecord; @@ -492,22 +492,22 @@ void CCrashHandler::FormatLoadedMods() { if (g_pModManager) { - spdlog::error("Enabled mods:"); + Error(eLog::NS, NO_ERROR, "Enabled mods:\n"); for (const Mod& mod : g_pModManager->m_LoadedMods) { if (!mod.m_bEnabled) continue; - spdlog::error("\t{}", mod.Name); + Error(eLog::NS, NO_ERROR, "\t%s\n", mod.Name.c_str()); } - spdlog::error("Disabled mods:"); + Error(eLog::NS, NO_ERROR, "Disabled mods:\n"); for (const Mod& mod : g_pModManager->m_LoadedMods) { if (mod.m_bEnabled) continue; - spdlog::error("\t{}", mod.Name); + Error(eLog::NS, NO_ERROR, "\t%s\n", mod.Name.c_str()); } } } @@ -519,10 +519,10 @@ void CCrashHandler::FormatLoadedPlugins() { if (g_pPluginManager) { - spdlog::error("Loaded Plugins:"); + Error(eLog::NS, NO_ERROR, "Loaded Plugins:\n"); for (const Plugin& plugin : g_pPluginManager->m_vLoadedPlugins) { - spdlog::error("\t{}", plugin.name); + Error(eLog::NS, NO_ERROR, "\t%s\n", plugin.name.c_str()); } } } @@ -532,7 +532,7 @@ void CCrashHandler::FormatLoadedPlugins() //----------------------------------------------------------------------------- void CCrashHandler::FormatModules() { - spdlog::error("Loaded modules:"); + Error(eLog::NS, NO_ERROR, "Loaded modules:\n"); HMODULE hModules[1024]; DWORD cbNeeded; @@ -544,7 +544,7 @@ void CCrashHandler::FormatModules() if (GetModuleFileNameExA(GetCurrentProcess(), hModules[i], szModulePath, sizeof(szModulePath))) { const CHAR* pszModuleFileName = strrchr(szModulePath, '\\') + 1; - spdlog::error("\t{}", pszModuleFileName); + Error(eLog::NS, NO_ERROR, "\t%s\n", pszModuleFileName); } } } @@ -579,7 +579,7 @@ void CCrashHandler::WriteMinidump() CloseHandle(hMinidumpFile); } else - spdlog::error("Failed to write minidump file {}!", stream.str()); + Error(eLog::NS, NO_ERROR, "Failed to write minidump file %s!\n", stream.str().c_str()); } //----------------------------------------------------------------------------- diff --git a/NorthstarDLL/mods/autodownload/moddownloader.cpp b/NorthstarDLL/mods/autodownload/moddownloader.cpp index 9c1489c65..cfff05b04 100644 --- a/NorthstarDLL/mods/autodownload/moddownloader.cpp +++ b/NorthstarDLL/mods/autodownload/moddownloader.cpp @@ -15,7 +15,7 @@ ModDownloader* g_pModDownloader; ModDownloader::ModDownloader() { - spdlog::info("Mod downloader initialized"); + DevMsg(eLog::NS, "Mod downloader initialized\n"); // Initialise mods list URI char* clachar = strstr(GetCommandLineA(), CUSTOM_MODS_URL_FLAG); @@ -36,12 +36,12 @@ ModDownloader::ModDownloader() int quote2 = (cla.substr(quote1 + 1)).find(quote); url = cla.substr(quote1 + 1, quote2); } - spdlog::info("Found custom verified mods URL in command line argument: {}", url); + DevMsg(eLog::NS, "Found custom verified mods URL in command line argument: %s\n", url.c_str()); modsListUrl = strdup(url.c_str()); } else { - spdlog::info("Custom verified mods URL not found in command line arguments, using default URL."); + DevMsg(eLog::NS, "Custom verified mods URL not found in command line arguments, using default URL.\n"); modsListUrl = strdup(DEFAULT_MODS_LIST_URL); } } @@ -77,16 +77,16 @@ void ModDownloader::FetchModsListFromAPI() if (result == CURLcode::CURLE_OK) { - spdlog::info("Mods list successfully fetched."); + DevMsg(eLog::NS, "Mods list successfully fetched.\n"); } else { - spdlog::error("Fetching mods list failed: {}", curl_easy_strerror(result)); + Error(eLog::NS, NO_ERROR, "Fetching mods list failed: %s\n", curl_easy_strerror(result)); goto REQUEST_END_CLEANUP; } // Load mods list into local state - spdlog::info("Loading mods configuration..."); + DevMsg(eLog::NS, "Loading mods configuration...\n"); verifiedModsJson.Parse(readBuffer); for (auto i = verifiedModsJson.MemberBegin(); i != verifiedModsJson.MemberEnd(); ++i) { @@ -106,10 +106,10 @@ void ModDownloader::FetchModsListFromAPI() VerifiedModDetails modConfig = {.dependencyPrefix = dependency, .versions = modVersions}; verifiedMods.insert({name, modConfig}); - spdlog::info("==> Loaded configuration for mod \"" + name + "\""); + DevMsg(eLog::NS, "==> Loaded configuration for mod \"%s\n", name.c_str()); } - spdlog::info("Done loading verified mods list."); + DevMsg(eLog::NS, "Done loading verified mods list.\n"); REQUEST_END_CLEANUP: curl_easy_cleanup(easyhandle); @@ -141,12 +141,12 @@ void FetchModSync(std::promise>&& p, std::string_view ur if (result == CURLcode::CURLE_OK) { - spdlog::info("Mod archive successfully fetched."); + DevMsg(eLog::NS, "Mod archive successfully fetched.\n"); goto REQUEST_END_CLEANUP; } else { - spdlog::error("Fetching mod archive failed: {}", curl_easy_strerror(result)); + Error(eLog::NS, NO_ERROR, "Fetching mod archive failed: %s\n", curl_easy_strerror(result)); failed = true; goto REQUEST_END_CLEANUP; } @@ -164,11 +164,11 @@ std::optional ModDownloader::FetchModFromDistantStore(std::string_view // Build archive distant URI std::string archiveName = std::format("{}-{}.zip", modPrefix, modVersion.data()); std::string url = STORE_URL + archiveName; - spdlog::info(std::format("Fetching mod archive from {}", url)); + DevMsg(eLog::NS, "Fetching mod archive from %s\n", url.c_str()); // Download destination std::filesystem::path downloadPath = std::filesystem::temp_directory_path() / archiveName; - spdlog::info(std::format("Downloading archive to {}", downloadPath.generic_string())); + DevMsg(eLog::NS, "Downloading archive to %s\n", downloadPath.c_str()); // Download the actual archive std::promise> promise; @@ -182,7 +182,7 @@ bool ModDownloader::IsModLegit(fs::path modPath, std::string_view expectedChecks { if (strstr(GetCommandLineA(), VERIFICATION_FLAG)) { - spdlog::info("Bypassing mod verification due to flag set up."); + DevMsg(eLog::NS, "Bypassing mod verification due to flag set up.\n"); return true; } @@ -241,7 +241,7 @@ bool ModDownloader::IsModLegit(fs::path modPath, std::string_view expectedChecks // Hash archive content if (!fp.is_open()) { - spdlog::error("Unable to open archive."); + Error(eLog::NS, NO_ERROR, "Unable to open archive.\n"); return false; } fp.seekg(0, fp.beg); @@ -279,8 +279,8 @@ bool ModDownloader::IsModLegit(fs::path modPath, std::string_view expectedChecks ss << std::hex << std::setw(2) << static_cast(hash.data()[i]); } - spdlog::info("Expected checksum: {}", expectedChecksum.data()); - spdlog::info("Computed checksum: {}", ss.str()); + DevMsg(eLog::NS, "Expected checksum: %s\n", expectedChecksum.data()); + DevMsg(eLog::NS, "Computed checksum: %s\n", ss.str().c_str()); return expectedChecksum.compare(ss.str()) == 0; cleanup: @@ -303,7 +303,7 @@ bool ModDownloader::IsModAuthorized(std::string_view modName, std::string_view m { if (strstr(GetCommandLineA(), VERIFICATION_FLAG)) { - spdlog::info("Bypassing mod verification due to flag set up."); + DevMsg(eLog::NS, "Bypassing mod verification due to flag set up.\n"); return true; } @@ -325,7 +325,7 @@ void ModDownloader::ExtractMod(fs::path modPath) file = unzOpen(modPath.generic_string().c_str()); if (file == NULL) { - spdlog::error("Cannot open archive located at {}.", modPath.generic_string()); + Error(eLog::NS, NO_ERROR, "Cannot open archive located at %s.\n", modPath.c_str()); goto EXTRACTION_CLEANUP; } @@ -334,7 +334,7 @@ void ModDownloader::ExtractMod(fs::path modPath) status = unzGetGlobalInfo64(file, &gi); if (status != UNZ_OK) { - spdlog::error("Failed getting information from archive (error code: {})", status); + Error(eLog::NS, NO_ERROR, "Failed getting information from archive (error code: %i)\n", status); goto EXTRACTION_CLEANUP; } @@ -353,15 +353,15 @@ void ModDownloader::ExtractMod(fs::path modPath) { std::error_code ec; fs::path fileDestination = modDirectory / zipFilename; - spdlog::info("=> {}", fileDestination.generic_string()); + DevMsg(eLog::NS, "=> %s\n", fileDestination.c_str()); // Create parent directory if needed if (!std::filesystem::exists(fileDestination.parent_path())) { - spdlog::info("Parent directory does not exist, creating it.", fileDestination.generic_string()); + DevMsg(eLog::NS, "Parent directory does not exist, creating it.\n", fileDestination.generic_string()); if (!std::filesystem::create_directories(fileDestination.parent_path(), ec) && ec.value() != 0) { - spdlog::error("Parent directory ({}) creation failed.", fileDestination.parent_path().generic_string()); + Error(eLog::NS, NO_ERROR, "Parent directory (%s) creation failed.\n", fileDestination.parent_path().c_str()); goto EXTRACTION_CLEANUP; } } @@ -372,7 +372,7 @@ void ModDownloader::ExtractMod(fs::path modPath) // Create directory if (!std::filesystem::create_directory(fileDestination, ec) && ec.value() != 0) { - spdlog::error("Directory creation failed: {}", ec.message()); + Error(eLog::NS, NO_ERROR, "Directory creation failed: %s\n", ec.message().c_str()); goto EXTRACTION_CLEANUP; } } @@ -382,7 +382,7 @@ void ModDownloader::ExtractMod(fs::path modPath) // Ensure file is in zip archive if (unzLocateFile(file, zipFilename, 0) != UNZ_OK) { - spdlog::error("File \"{}\" was not found in archive.", zipFilename); + Error(eLog::NS, NO_ERROR, "File \"%s\" was not found in archive.\n", zipFilename); goto EXTRACTION_CLEANUP; } @@ -396,7 +396,7 @@ void ModDownloader::ExtractMod(fs::path modPath) status = unzOpenCurrentFile(file); if (status != UNZ_OK) { - spdlog::error("Could not open file {} from archive.", zipFilename); + Error(eLog::NS, NO_ERROR, "Could not open file %s from archive.\n", zipFilename); goto EXTRACTION_CLEANUP; } @@ -404,7 +404,7 @@ void ModDownloader::ExtractMod(fs::path modPath) fout = fopen(fileDestination.generic_string().c_str(), "wb"); if (fout == NULL) { - spdlog::error("Failed creating destination file."); + Error(eLog::NS, NO_ERROR, "Failed creating destination file.\n"); goto EXTRACTION_CLEANUP; } @@ -412,7 +412,7 @@ void ModDownloader::ExtractMod(fs::path modPath) buffer = (void*)malloc(bufferSize); if (buffer == NULL) { - spdlog::error("Error while allocating memory."); + Error(eLog::NS, NO_ERROR, "Error while allocating memory.\n"); goto EXTRACTION_CLEANUP; } @@ -422,14 +422,14 @@ void ModDownloader::ExtractMod(fs::path modPath) err = unzReadCurrentFile(file, buffer, bufferSize); if (err < 0) { - spdlog::error("error {} with zipfile in unzReadCurrentFile", err); + Error(eLog::NS, NO_ERROR, "error %i with zipfile in unzReadCurrentFile\n", err); break; } if (err > 0) { if (fwrite(buffer, (unsigned)err, 1, fout) != 1) { - spdlog::error("error in writing extracted file\n"); + Error(eLog::NS, NO_ERROR, "error in writing extracted file\n"); err = UNZ_ERRNO; break; } @@ -438,13 +438,13 @@ void ModDownloader::ExtractMod(fs::path modPath) if (err != UNZ_OK) { - spdlog::error("An error occurred during file extraction (code: {})", err); + Error(eLog::NS, NO_ERROR, "An error occurred during file extraction (code: %i)\n", err); goto EXTRACTION_CLEANUP; } err = unzCloseCurrentFile(file); if (err != UNZ_OK) { - spdlog::error("error {} with zipfile in unzCloseCurrentFile", err); + Error(eLog::NS, NO_ERROR, "error %i with zipfile in unzCloseCurrentFile\n", err); } // Cleanup @@ -459,7 +459,7 @@ void ModDownloader::ExtractMod(fs::path modPath) status = unzGoToNextFile(file); if (status != UNZ_OK) { - spdlog::error("Error while browsing archive files (error code: {}).", status); + Error(eLog::NS, NO_ERROR, "Error while browsing archive files (error code: %i).\n", status); goto EXTRACTION_CLEANUP; } } @@ -468,7 +468,7 @@ void ModDownloader::ExtractMod(fs::path modPath) EXTRACTION_CLEANUP: if (unzClose(file) != MZ_OK) { - spdlog::error("Failed closing mod archive after extraction."); + Error(eLog::NS, NO_ERROR, "Failed closing mod archive after extraction.\n"); } } @@ -477,7 +477,7 @@ void ModDownloader::DownloadMod(std::string modName, std::string modVersion) // Check if mod can be auto-downloaded if (!IsModAuthorized(std::string_view(modName), std::string_view(modVersion))) { - spdlog::warn("Tried to download a mod that is not verified, aborting."); + Warning(eLog::NS, "Tried to download a mod that is not verified, aborting.\n"); return; } @@ -491,13 +491,13 @@ void ModDownloader::DownloadMod(std::string modName, std::string modVersion) std::optional fetchingResult = FetchModFromDistantStore(std::string_view(modName), std::string_view(modVersion)); if (!fetchingResult.has_value()) { - spdlog::error("Something went wrong while fetching archive, aborting."); + Error(eLog::NS, NO_ERROR, "Something went wrong while fetching archive, aborting.\n"); goto REQUEST_END_CLEANUP; } archiveLocation = fetchingResult.value(); if (!IsModLegit(archiveLocation, std::string_view(expectedHash))) { - spdlog::warn("Archive hash does not match expected checksum, aborting."); + Warning(eLog::NS, "Archive hash does not match expected checksum, aborting.\n"); goto REQUEST_END_CLEANUP; } @@ -511,10 +511,10 @@ void ModDownloader::DownloadMod(std::string modName, std::string modVersion) } catch (const std::exception& a) { - spdlog::error("Error while removing downloaded archive: {}", a.what()); + Error(eLog::NS, NO_ERROR, "Error while removing downloaded archive: %s\n", a.what()); } - spdlog::info("Done downloading {}.", modName); + DevMsg(eLog::NS, "Done downloading %s.\n", modName.c_str()); }); requestThread.detach(); diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp index 282e2440d..f3cebe8f8 100644 --- a/NorthstarDLL/mods/modmanager.cpp +++ b/NorthstarDLL/mods/modmanager.cpp @@ -677,7 +677,7 @@ void ModManager::LoadMods() // Use regex to match `AUTHOR-MOD-VERSION` pattern if (!std::regex_match(dir.path().string(), pattern)) { - spdlog::warn("The following directory did not match 'AUTHOR-MOD-VERSION': {}", dir.path().string()); + Warning(eLog::MODSYS, "The following directory did not match 'AUTHOR-MOD-VERSION': %s\n", dir.path().c_str()); continue; // skip loading mod that doesn't match } if (fs::exists(modsDir) && fs::is_directory(modsDir)) diff --git a/NorthstarDLL/mods/modsavefiles.cpp b/NorthstarDLL/mods/modsavefiles.cpp index f8e5848c6..82344cfb5 100644 --- a/NorthstarDLL/mods/modsavefiles.cpp +++ b/NorthstarDLL/mods/modsavefiles.cpp @@ -85,7 +85,7 @@ template void SaveFileManager::SaveFileAsync(fs::path fi if (GetSizeOfFolderContentsMinusFile(dir, file.filename().string()) + contents.length() > MAX_FOLDER_SIZE) { // tbh, you're either trying to fill the hard drive or use so much data, you SHOULD be congratulated. - spdlog::error(fmt::format("Mod spamming save requests? Folder limit bypassed despite previous checks. Not saving.")); + Error(eLog::NS, NO_ERROR, "Mod spamming save requests? Folder limit bypassed despite previous checks. Not saving.\n"); mutex.get().unlock(); return; } @@ -108,9 +108,9 @@ template void SaveFileManager::SaveFileAsync(fs::path fi } catch (std::exception ex) { - spdlog::error("SAVE FAILED!"); + Error(eLog::NS, NO_ERROR, "SAVE FAILED!\n"); mutex.get().unlock(); - spdlog::error(ex.what()); + Error(eLog::NS, NO_ERROR, ex.what() << '\n'); } }); @@ -132,7 +132,7 @@ template int SaveFileManager::LoadFileAsync(fs::path fil std::ifstream fileStr(file); if (fileStr.fail()) { - spdlog::error("A file was supposed to be loaded but we can't access it?!"); + Error(eLog::NS, NO_ERROR, "A file was supposed to be loaded but we can't access it?!\n"); g_pSquirrel->AsyncCall("NSHandleLoadResult", handle, false, ""); mutex.get().unlock(); @@ -153,10 +153,10 @@ template int SaveFileManager::LoadFileAsync(fs::path fil } catch (std::exception ex) { - spdlog::error("LOAD FAILED!"); + Error(eLog::NS, NO_ERROR, "LOAD FAILED!\n"); g_pSquirrel->AsyncCall("NSHandleLoadResult", handle, false, ""); mutex.get().unlock(); - spdlog::error(ex.what()); + Error(eLog::NS, NO_ERROR, ex.what() << '\n'); } }); @@ -186,9 +186,9 @@ template void SaveFileManager::DeleteFileAsync(fs::path } catch (std::exception ex) { - spdlog::error("DELETE FAILED!"); + Error(eLog::NS, NO_ERROR, "DELETE FAILED!\n"); m.get().unlock(); - spdlog::error(ex.what()); + Error(eLog::NS, NO_ERROR, ex.what() << '\n'); } }); @@ -420,7 +420,7 @@ ADD_SQFUNC("int", NSGetFileSize, "string file", "", ScriptContext::SERVER | Scri } catch (std::filesystem::filesystem_error const& ex) { - spdlog::error("GET FILE SIZE FAILED! Is the path valid?"); + Error(eLog::NS, NO_ERROR, "GET FILE SIZE FAILED! Is the path valid?\n"); g_pSquirrel->raiseerror(sqvm, ex.what()); return SQRESULT_ERROR; } @@ -485,7 +485,7 @@ ADD_SQFUNC("array", NS_InternalGetAllFiles, "string path", "", ScriptCon } catch (std::exception ex) { - spdlog::error("DIR ITERATE FAILED! Is the path valid?"); + Error(eLog::NS, NO_ERROR, "DIR ITERATE FAILED! Is the path valid?\n"); g_pSquirrel->raiseerror(sqvm, ex.what()); return SQRESULT_ERROR; } @@ -518,8 +518,7 @@ ADD_SQFUNC("bool", NSIsFolder, "string path", "", ScriptContext::CLIENT | Script } catch (std::exception ex) { - spdlog::error("DIR READ FAILED! Is the path valid?"); - spdlog::info(path.string()); + Error(eLog::NS, NO_ERROR, "DIR READ FAILED! Is the path valid? %s\n", path.c_str()); g_pSquirrel->raiseerror(sqvm, ex.what()); return SQRESULT_ERROR; } diff --git a/NorthstarDLL/squirrel/squirrelclasstypes.h b/NorthstarDLL/squirrel/squirrelclasstypes.h index c193f2fc5..234091c95 100644 --- a/NorthstarDLL/squirrel/squirrelclasstypes.h +++ b/NorthstarDLL/squirrel/squirrelclasstypes.h @@ -158,7 +158,7 @@ class SquirrelMessageBuffer auto maybeMessage = this->pop(); if (!maybeMessage) { - spdlog::error("Plugin tried consuming SquirrelMessage while buffer was empty"); + Error(eLog::PLUGSYS, NO_ERROR, "Plugin tried consuming SquirrelMessage while buffer was empty\n"); return; } auto message = maybeMessage.value(); diff --git a/NorthstarDLL/util/printcommands.cpp b/NorthstarDLL/util/printcommands.cpp index 989ae77a3..03c1ac270 100644 --- a/NorthstarDLL/util/printcommands.cpp +++ b/NorthstarDLL/util/printcommands.cpp @@ -205,7 +205,7 @@ void ConCommand_list(const CCommand& arg) { PrintCommandHelpDialogue(map.second, map.second->m_pszName); } - spdlog::info("{} total convars/concommands", sorted.size()); + DevMsg(eLog::NS, "%z total convars/concommands\n", sorted.size()); } void ConCommand_differences(const CCommand& arg) @@ -255,8 +255,8 @@ void ConCommand_differences(const CCommand& arg) formatted.append(fmt::format(" max. {}", cvar->m_fMaxVal)); } - formatted.append(fmt::format(" - {}", cvar->GetHelpText())); - spdlog::info(formatted); + formatted.append(fmt::format(" - {}\n", cvar->GetHelpText())); + DevMsg(eLog::NS, formatted.c_str()); } }