From 7ef37e180a3960306b0f3c8d4b4ea3b61d3ec4f1 Mon Sep 17 00:00:00 2001 From: Mrna Date: Tue, 23 Sep 2025 15:31:39 +0200 Subject: [PATCH] Provide MSVC alternative for __PRETTY_FUNCTION__ --- cpp/src/log.hpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cpp/src/log.hpp b/cpp/src/log.hpp index e8bcffe..2f1cb6d 100644 --- a/cpp/src/log.hpp +++ b/cpp/src/log.hpp @@ -2,13 +2,21 @@ #include -#define LOG_CRITICAL(...) Log::critical(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) -#define LOG_ERROR(...) Log::error(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) -#define LOG_WARNING(...) Log::warning(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) -#define LOG_INFO(...) Log::info(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) -#define LOG_DEBUG(...) Log::debug(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) +#if defined(__GNUC__) || defined(__clang__) +# define PRETTY_FUNC __PRETTY_FUNCTION__ +#elif defined(_MSC_VER) +# define PRETTY_FUNC __FUNCTION__ +#else +# define PRETTY_FUNC __func__ +#endif + +#define LOG_CRITICAL(...) Log::critical(PRETTY_FUNC, ": ", __VA_ARGS__) +#define LOG_ERROR(...) Log::error(PRETTY_FUNC, ": ", __VA_ARGS__) +#define LOG_WARNING(...) Log::warning(PRETTY_FUNC, ": ", __VA_ARGS__) +#define LOG_INFO(...) Log::info(PRETTY_FUNC, ": ", __VA_ARGS__) +#define LOG_DEBUG(...) Log::debug(PRETTY_FUNC, ": ", __VA_ARGS__) #define LOG_PROFILING_DEBUG(...) \ - Log::profiling_debug(__PRETTY_FUNCTION__, ": ", __VA_ARGS__) + Log::profiling_debug(PRETTY_FUNC, ": ", __VA_ARGS__) namespace Log { enum class LevelTypes {