Merge pull request #14 from Servostar/13-fix-log-macro

13 fix log macro
This commit is contained in:
servostar 2024-04-17 13:22:22 +00:00 committed by GitHub
commit 159ab707fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <stdio.h>
#include <sys/cdefs.h>
#include <string.h>
#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