Skip to content

Commit 991cd1a

Browse files
authored
Merge pull request #16 from ErezBinyamin/patch-1
2 parents 9874696 + bf92ac2 commit 991cd1a

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

DebugLogEnable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#define LOG_SHORT_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
1010

1111
// C pre-proc Token Concatenation: https://wiki.sei.cmu.edu/confluence/display/c/PRE05-C.+Understand+macro+replacement+when+concatenating+tokens+or+performing+stringification
12-
#define xstr(s) str(s)
13-
#define str(s) #s
12+
#define LOG_MACRO_APPEND_STR(s) LOG_HELPER_MACRO_APPEND_STR(s)
13+
#define LOG_HELPER_MACRO_APPEND_STR(s) #s
1414

1515
#ifndef LOG_PREAMBLE
16-
#define LOG_PREAMBLE LOG_SHORT_FILENAME, xstr(L.__LINE__), __func__, ":"
16+
#define LOG_PREAMBLE LOG_SHORT_FILENAME, LOG_MACRO_APPEND_STR(L.__LINE__), __func__, ":"
1717
#endif
1818

1919
#if defined(DEBUGLOG_DEFAULT_LOG_LEVEL_ERROR)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ LOG_INFO("Message 3");
115115
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.
116116

117117
```C++
118-
#define LOG_PREAMBLE LOG_SHORT_FILENAME, xstr(L.__LINE__), __func__, ":"
118+
#define LOG_PREAMBLE LOG_SHORT_FILENAME, LOG_MACRO_APPEND_STR(L.__LINE__), __func__, ":"
119119
```
120120
121+
> The `LOG_MACRO_APPEND_STR()` macro will append a string to the result of a second macro
122+
121123
### Assertion
122124
123125
`ASSERT` suspends program if the provided condition is `false`

0 commit comments

Comments
 (0)