File size: 2,592 Bytes
d1be154 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #ifndef OT_STATIC_LOGGER_HPP_
#define OT_STATIC_LOGGER_HPP_
#include <ot/utility/logger.hpp>
#include <ot/policy.hpp>
namespace ot {
// Global declaration and macro usage.
inline Logger logger(env::log_file());
}; // end of namespace ot. ------------------------------------------------------------------------
#define OT_LOG_REMOVE_FIRST_HELPER(N, ...) __VA_ARGS__
#define OT_LOG_GET_FIRST_HELPER(N, ...) N
#define OT_LOG_GET_FIRST(...) OT_LOG_GET_FIRST_HELPER(__VA_ARGS__)
#define OT_LOG_REMOVE_FIRST(...) OT_LOG_REMOVE_FIRST_HELPER(__VA_ARGS__)
#define OT_LOGTO(...) ot::logger.redir (__VA_ARGS__)
#define OT_LOG(...) ot::logger.raw (__VA_ARGS__)
#define OT_LOGD(...) ot::logger.debug (__FILE__, __LINE__, __VA_ARGS__, '\n')
#define OT_LOGI(...) ot::logger.info (__FILE__, __LINE__, __VA_ARGS__, '\n')
#define OT_LOGW(...) ot::logger.warning(__FILE__, __LINE__, __VA_ARGS__, '\n')
#define OT_LOGE(...) ot::logger.error (__FILE__, __LINE__, __VA_ARGS__, '\n')
#define OT_LOGF(...) ot::logger.fatal (__FILE__, __LINE__, __VA_ARGS__, '\n')
#define OT_LOG_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOG(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGD_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGD(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGI_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGI(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGW_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGW(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGE_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGE(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGF_IF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGF(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
}
#define OT_LOGW_RIF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGW(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
return; \
}
#define OT_LOGE_RIF(...) if(OT_LOG_GET_FIRST(__VA_ARGS__)) { \
OT_LOGE(OT_LOG_REMOVE_FIRST(__VA_ARGS__)); \
return; \
}
#endif
|