29#ifndef SBL_LOG_MACROS_HPP_
30#define SBL_LOG_MACROS_HPP_
38 #define SBL_LOG_LEVEL 3
42#define SBL_LOG_LEVEL_OFF 0
43#define SBL_LOG_LEVEL_ERROR 1
44#define SBL_LOG_LEVEL_WARN 2
45#define SBL_LOG_LEVEL_INFO 3
46#define SBL_LOG_LEVEL_DEBUG 4
47#define SBL_LOG_LEVEL_TRACE 5
51 #if SBL_LOG_USB_DEFAULTS_AVAILABLE
52 #define SBL_LOG_OUTPUT sbl::usb::CdcOutput
53 #elif SBL_LOG_HW_DEFAULTS_AVAILABLE
54 #define SBL_LOG_OUTPUT sbl::log::UartOutput
56 #define SBL_LOG_OUTPUT sbl::log::NullOutput
61#ifndef SBL_LOG_TIMESTAMP
62 #if SBL_LOG_HW_DEFAULTS_AVAILABLE
63 #define SBL_LOG_TIMESTAMP sbl::log::TimerTimestamp
65 #define SBL_LOG_TIMESTAMP sbl::log::NullTimestamp
72 return static_cast<Level>(lvl);
89#if SBL_LOG_LEVEL >= SBL_LOG_LEVEL_ERROR
90 #define SBL_LOG_ERROR(...) \
91 SblLogger_::log(sbl::log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
93 #define SBL_LOG_ERROR(...) ((void)0)
96#if SBL_LOG_LEVEL >= SBL_LOG_LEVEL_WARN
97 #define SBL_LOG_WARN(...) \
98 SblLogger_::log(sbl::log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
100 #define SBL_LOG_WARN(...) ((void)0)
103#if SBL_LOG_LEVEL >= SBL_LOG_LEVEL_INFO
104 #define SBL_LOG_INFO(...) \
105 SblLogger_::log(sbl::log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
107 #define SBL_LOG_INFO(...) ((void)0)
110#if SBL_LOG_LEVEL >= SBL_LOG_LEVEL_DEBUG
111 #define SBL_LOG_DEBUG(...) \
112 SblLogger_::log(sbl::log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
114 #define SBL_LOG_DEBUG(...) ((void)0)
117#if SBL_LOG_LEVEL >= SBL_LOG_LEVEL_TRACE
118 #define SBL_LOG_TRACE(...) \
119 SblLogger_::log(sbl::log::Level::Trace, __FILE__, __LINE__, __VA_ARGS__)
121 #define SBL_LOG_TRACE(...) ((void)0)
127#define SBL_LOG_ERROR_IF(cond, ...) \
128 do { if (cond) { SBL_LOG_ERROR(__VA_ARGS__); } } while(0)
130#define SBL_LOG_WARN_IF(cond, ...) \
131 do { if (cond) { SBL_LOG_WARN(__VA_ARGS__); } } while(0)
133#define SBL_LOG_INFO_IF(cond, ...) \
134 do { if (cond) { SBL_LOG_INFO(__VA_ARGS__); } } while(0)
139#if SBL_LOG_LEVEL > SBL_LOG_LEVEL_OFF
140 #define SBL_LOG_SIMPLE(lvl, ...) \
141 SblLogger_::log_simple(lvl, __VA_ARGS__)
143 #define SBL_LOG_SIMPLE(lvl, ...) ((void)0)
Logger class with compile-time level filtering.
Default logger output sink and timestamp provider.
Logger class with timestamp provider and output sink.
#define SBL_LOG_TIMESTAMP
constexpr Level level_from_int(int lvl)
Level
Log severity levels.