10#if defined(MOMENTUM_WITH_XR_LOGGER)
16#ifndef DEFAULT_LOG_CHANNEL
18#define DEFAULT_LOG_CHANNEL MOMENTUM_LOG_CHANNEL
21#include <logging/Log.h>
26#define MT_LOGT(...) XR_LOGT(__VA_ARGS__)
27#define MT_LOGD(...) XR_LOGD(__VA_ARGS__)
28#define MT_LOGI(...) XR_LOGI(__VA_ARGS__)
29#define MT_LOGW(...) XR_LOGW(__VA_ARGS__)
30#define MT_LOGE(...) XR_LOGE(__VA_ARGS__)
35#define MT_LOGT_IF(condition, ...) XR_LOGT_IF(condition, __VA_ARGS__)
36#define MT_LOGD_IF(condition, ...) XR_LOGD_IF(condition, __VA_ARGS__)
37#define MT_LOGI_IF(condition, ...) XR_LOGI_IF(condition, __VA_ARGS__)
38#define MT_LOGW_IF(condition, ...) XR_LOGW_IF(condition, __VA_ARGS__)
39#define MT_LOGE_IF(condition, ...) XR_LOGE_IF(condition, __VA_ARGS__)
44#define MT_LOGT_ONCE(...) XR_LOGT_ONCE(__VA_ARGS__)
45#define MT_LOGD_ONCE(...) XR_LOGD_ONCE(__VA_ARGS__)
46#define MT_LOGI_ONCE(...) XR_LOGI_ONCE(__VA_ARGS__)
47#define MT_LOGW_ONCE(...) XR_LOGW_ONCE(__VA_ARGS__)
48#define MT_LOGE_ONCE(...) XR_LOGE_ONCE(__VA_ARGS__)
53#define MT_LOGT_ONCE_IF(condition, ...) XR_LOGT_ONCE_IF(condition, __VA_ARGS__)
54#define MT_LOGD_ONCE_IF(condition, ...) XR_LOGD_ONCE_IF(condition, __VA_ARGS__)
55#define MT_LOGI_ONCE_IF(condition, ...) XR_LOGI_ONCE_IF(condition, __VA_ARGS__)
56#define MT_LOGW_ONCE_IF(condition, ...) XR_LOGW_ONCE_IF(condition, __VA_ARGS__)
57#define MT_LOGE_ONCE_IF(condition, ...) XR_LOGE_ONCE_IF(condition, __VA_ARGS__)
60#elif defined(MOMENTUM_WITH_SPDLOG)
62#include <spdlog/spdlog.h>
69#define MT_LOGT(...) ::spdlog::trace(__VA_ARGS__)
70#define MT_LOGD(...) ::spdlog::debug(__VA_ARGS__)
71#define MT_LOGI(...) ::spdlog::info(__VA_ARGS__)
72#define MT_LOGW(...) ::spdlog::warn(__VA_ARGS__)
73#define MT_LOGE(...) ::spdlog::error(__VA_ARGS__)
78#define MT_LOGT_IF(condition, ...) \
81 MT_LOGT(__VA_ARGS__); \
84#define MT_LOGD_IF(condition, ...) \
87 MT_LOGD(__VA_ARGS__); \
90#define MT_LOGI_IF(condition, ...) \
93 MT_LOGI(__VA_ARGS__); \
96#define MT_LOGW_IF(condition, ...) \
99 MT_LOGW(__VA_ARGS__); \
102#define MT_LOGE_IF(condition, ...) \
105 MT_LOGE(__VA_ARGS__); \
115#define MT_DETAIL_RUN_ONCE(runcode) \
117 static std::atomic<bool> codeRan(false); \
119 bool expected = false; \
120 if (codeRan.compare_exchange_strong(expected, true)) { \
128#define MT_LOGT_ONCE(...) MT_DETAIL_RUN_ONCE(MT_LOGT(__VA_ARGS__))
129#define MT_LOGD_ONCE(...) MT_DETAIL_RUN_ONCE(MT_LOGD(__VA_ARGS__))
130#define MT_LOGI_ONCE(...) MT_DETAIL_RUN_ONCE(MT_LOGI(__VA_ARGS__))
131#define MT_LOGW_ONCE(...) MT_DETAIL_RUN_ONCE(MT_LOGW(__VA_ARGS__))
132#define MT_LOGE_ONCE(...) MT_DETAIL_RUN_ONCE(MT_LOGE(__VA_ARGS__))
140#define MT_LOGT_ONCE_IF(condition, ...) \
143 MT_LOGT_ONCE(__VA_ARGS__); \
146#define MT_LOGD_ONCE_IF(condition, ...) \
149 MT_LOGD_ONCE(__VA_ARGS__); \
152#define MT_LOGI_ONCE_IF(condition, ...) \
155 MT_LOGI_ONCE(__VA_ARGS__); \
158#define MT_LOGW_ONCE_IF(condition, ...) \
161 MT_LOGW_ONCE(__VA_ARGS__); \
164#define MT_LOGE_ONCE_IF(condition, ...) \
167 MT_LOGE_ONCE(__VA_ARGS__); \
183#define MT_LOGT_IF(condition, ...)
184#define MT_LOGD_IF(condition, ...)
185#define MT_LOGI_IF(condition, ...)
186#define MT_LOGW_IF(condition, ...)
187#define MT_LOGE_IF(condition, ...)
189#define MT_LOGT_ONCE(...)
190#define MT_LOGD_ONCE(...)
191#define MT_LOGI_ONCE(...)
192#define MT_LOGW_ONCE(...)
193#define MT_LOGE_ONCE(...)
195#define MT_LOGT_ONCE_IF(condition, ...)
196#define MT_LOGD_ONCE_IF(condition, ...)
197#define MT_LOGI_ONCE_IF(condition, ...)
198#define MT_LOGW_ONCE_IF(condition, ...)
199#define MT_LOGE_ONCE_IF(condition, ...)
224[[nodiscard]] std::map<std::string, LogLevel>
logLevelMap();
LogLevel
Logging levels in ascending order of verbosity.
void setLogLevel(LogLevel level)
Sets the global log threshold; messages below level are filtered out.
std::map< std::string, LogLevel > logLevelMap()
Returns the canonical mapping from human-readable level names ("Disabled", "Error",...
LogLevel getLogLevel()
Returns the current global log threshold.