Skip to content

Commit 042c9b7

Browse files
authored
Make debug and verbose level logging in release builds optional (#2006)
* Debug (AXLOGD) and verbose (AXLOGV) level logging should be disabled by default in release builds. * Fix preprocessor check
1 parent d1ca753 commit 042c9b7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/base/Logging.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,20 @@ inline void printLogT(_FmtType&& fmt, LogItem& item, _Types&&... args)
139139
#define AXLOG_WITH_LEVEL(level, fmtOrMsg, ...) \
140140
ax::printLogT(FMT_COMPILE("{}" fmtOrMsg "\n"), ax::preprocessLog(ax::LogItem{level}), ##__VA_ARGS__)
141141

142-
#define AXLOGV(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Verbose, fmtOrMsg, ##__VA_ARGS__)
143-
#define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
142+
#if defined(_AX_DEBUG) && _AX_DEBUG > 0
143+
# define AXLOGV(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Verbose, fmtOrMsg, ##__VA_ARGS__)
144+
# define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
145+
#else
146+
# define AXLOGV(...) \
147+
do \
148+
{ \
149+
} while (0)
150+
# define AXLOGD(...) \
151+
do \
152+
{ \
153+
} while (0)
154+
#endif
155+
144156
#define AXLOGI(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Info, fmtOrMsg, ##__VA_ARGS__)
145157
#define AXLOGW(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Warn, fmtOrMsg, ##__VA_ARGS__)
146158
#define AXLOGE(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Error, fmtOrMsg, ##__VA_ARGS__)

0 commit comments

Comments
 (0)