From 62d5e611f17a8d9896886e17b8244f6cb51d9b4f Mon Sep 17 00:00:00 2001 From: SirLynix Date: Mon, 4 Dec 2023 18:22:40 +0100 Subject: [PATCH] Core/Error: Make error log only the filename where the error occurred --- include/Nazara/Core/Error.hpp | 2 +- include/Nazara/Core/Error.inl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Core/Error.hpp b/include/Nazara/Core/Error.hpp index c9b201417..bf2992438 100644 --- a/include/Nazara/Core/Error.hpp +++ b/include/Nazara/Core/Error.hpp @@ -38,7 +38,7 @@ namespace Nz static ErrorModeFlags ApplyFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags); - static constexpr std::string_view GetCurrentFileRelativeToEngine(std::string_view file); + static constexpr std::string_view TranslateFilepath(std::string_view file); static ErrorModeFlags GetFlags(); static std::string GetLastError(std::string_view* file = nullptr, unsigned int* line = nullptr, std::string_view* function = nullptr); static unsigned int GetLastSystemErrorCode(); diff --git a/include/Nazara/Core/Error.inl b/include/Nazara/Core/Error.inl index f7e90234f..80d539d92 100644 --- a/include/Nazara/Core/Error.inl +++ b/include/Nazara/Core/Error.inl @@ -4,12 +4,12 @@ namespace Nz { - constexpr std::string_view Error::GetCurrentFileRelativeToEngine(std::string_view file) + constexpr std::string_view Error::TranslateFilepath(std::string_view file) { - if (std::size_t offset = file.find("NazaraEngine/"); offset != file.npos) + if (std::size_t offset = file.rfind('/'); offset != file.npos) return file.substr(offset); - if (std::size_t offset = file.find("NazaraEngine\\"); offset != file.npos) + if (std::size_t offset = file.rfind('\\'); offset != file.npos) return file.substr(offset); return file; @@ -22,6 +22,6 @@ namespace Nz inline void Error::Trigger(ErrorType type, unsigned int line, std::string_view file, std::string_view function, std::string error) { - return TriggerInternal(type, std::move(error), line, GetCurrentFileRelativeToEngine(file), function); + return TriggerInternal(type, std::move(error), line, TranslateFilepath(file), function); } }