diff --git a/DebugLogEnable.h b/DebugLogEnable.h index 0a59e7a..2fe9d43 100644 --- a/DebugLogEnable.h +++ b/DebugLogEnable.h @@ -9,11 +9,11 @@ #define LOG_SHORT_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) // C pre-proc Token Concatenation: https://wiki.sei.cmu.edu/confluence/display/c/PRE05-C.+Understand+macro+replacement+when+concatenating+tokens+or+performing+stringification -#define xstr(s) str(s) -#define str(s) #s +#define LOG_MACRO_APPEND_STR(s) LOG_HELPER_MACRO_APPEND_STR(s) +#define LOG_HELPER_MACRO_APPEND_STR(s) #s #ifndef LOG_PREAMBLE - #define LOG_PREAMBLE LOG_SHORT_FILENAME, xstr(L.__LINE__), __func__, ":" + #define LOG_PREAMBLE LOG_SHORT_FILENAME, LOG_MACRO_APPEND_STR(L.__LINE__), __func__, ":" #endif #if defined(DEBUGLOG_DEFAULT_LOG_LEVEL_ERROR) diff --git a/README.md b/README.md index 35921e8..20e0fbb 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,11 @@ LOG_INFO("Message 3"); The Default `LOG_PREAMBLE` calls other macros and functions. _Note_ the comma separated fields will be space delimeted as they are inputs to the `LOG_XXXX(...)` macro. ```C++ -#define LOG_PREAMBLE LOG_SHORT_FILENAME, xstr(L.__LINE__), __func__, ":" +#define LOG_PREAMBLE LOG_SHORT_FILENAME, LOG_MACRO_APPEND_STR(L.__LINE__), __func__, ":" ``` +> The `LOG_MACRO_APPEND_STR()` macro will append a string to the result of a second macro + ### Assertion `ASSERT` suspends program if the provided condition is `false`