diff --git a/src/sys/log.h b/src/sys/log.h index 84d0440..f582eb9 100644 --- a/src/sys/log.h +++ b/src/sys/log.h @@ -3,6 +3,7 @@ #include #include +#include #define LOG_DEFAULT_STREAM stderr @@ -20,6 +21,16 @@ #define LOG_STRING_INFORMATION "Information" #define LOG_STRING_DEBUG "Debug" +// define __FILE_NAME__ macro if not defined +// generally not defined by GCC < 11.3 and MSVC +#ifndef __FILE_NAME__ +#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) +#define __FILE_NAME__ (strrstr(__FILE__, "\\\\") ? strrstr(__FILE__, "\\\\") + 1 : __FILE__) +#else +#define __FILE_NAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#endif +#endif + /** * @brief Panic is used in cases where the process is in an unrecoverable state. * This macro will print debug information to stderr and call abort() to