Skip to content

Commit

Permalink
Make debug and verbose level logging in release builds optional (axmo…
Browse files Browse the repository at this point in the history
…lengine#2006)

* Debug (AXLOGD) and verbose (AXLOGV) level logging should be disabled by default in release builds.

* Fix preprocessor check
  • Loading branch information
rh101 authored Jun 27, 2024
1 parent d1ca753 commit 042c9b7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/base/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,20 @@ inline void printLogT(_FmtType&& fmt, LogItem& item, _Types&&... args)
#define AXLOG_WITH_LEVEL(level, fmtOrMsg, ...) \
ax::printLogT(FMT_COMPILE("{}" fmtOrMsg "\n"), ax::preprocessLog(ax::LogItem{level}), ##__VA_ARGS__)

#define AXLOGV(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Verbose, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
#if defined(_AX_DEBUG) && _AX_DEBUG > 0
# define AXLOGV(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Verbose, fmtOrMsg, ##__VA_ARGS__)
# define AXLOGD(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Debug, fmtOrMsg, ##__VA_ARGS__)
#else
# define AXLOGV(...) \
do \
{ \
} while (0)
# define AXLOGD(...) \
do \
{ \
} while (0)
#endif

#define AXLOGI(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Info, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGW(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Warn, fmtOrMsg, ##__VA_ARGS__)
#define AXLOGE(fmtOrMsg, ...) AXLOG_WITH_LEVEL(ax::LogLevel::Error, fmtOrMsg, ##__VA_ARGS__)
Expand Down

0 comments on commit 042c9b7

Please sign in to comment.