MIP_SDK
v3.0.0-502-gc890c1c
MicroStrain Communications Library for embedded systems
|
Go to the documentation of this file.
88 #ifdef MICROSTRAIN_ENABLE_LOGGING
89 #define MICROSTRAIN_LOG_INIT(callback, level, user) microstrain_logging_init(callback, level, user)
91 #define MICROSTRAIN_LOG_INIT(callback, level, user) (void)0
100 #ifdef MICROSTRAIN_ENABLE_LOGGING
101 #define MICROSTRAIN_LOG_LOG(level, ...) microstrain_logging_log(level, __VA_ARGS__)
102 #define MICROSTRAIN_LOG_LOG_V(level, fmt, args) microstrain_logging_log_v(level, fmt, args)
104 #define MICROSTRAIN_LOG_LOG(level, ...) (void)0
105 #define MICROSTRAIN_LOG_LOG_V(level, fmt, args) (void)0
108 #ifndef MICROSTRAIN_LOGGING_MAX_LEVEL
109 #define MICROSTRAIN_LOGGING_MAX_LEVEL MICROSTRAIN_LOG_LEVEL_WARN
121 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_FATAL
122 #define MICROSTRAIN_LOG_FATAL(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_FATAL, __VA_ARGS__)
123 #define MICROSTRAIN_LOG_FATAL_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_FATAL, fmt, args)
125 #define MICROSTRAIN_LOG_FATAL(...) (void)0
126 #define MICROSTRAIN_LOG_FATAL_V(fmt, args) (void)0
134 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_ERROR
135 #define MICROSTRAIN_LOG_ERROR(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_ERROR, __VA_ARGS__)
136 #define MICROSTRAIN_LOG_ERROR_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_ERROR, fmt, args)
138 #define MICROSTRAIN_LOG_ERROR(...) (void)0
139 #define MICROSTRAIN_LOG_ERROR_V(fmt, args) (void)0
146 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_WARN
147 #define MICROSTRAIN_LOG_WARN(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_WARN, __VA_ARGS__)
148 #define MICROSTRAIN_LOG_WARN_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_WARN, fmt, args)
150 #define MICROSTRAIN_LOG_WARN(...) (void)0
151 #define MICROSTRAIN_LOG_WARN_V(fmt, args) (void)0
158 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_INFO
159 #define MICROSTRAIN_LOG_INFO(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_INFO, __VA_ARGS__)
160 #define MICROSTRAIN_LOG_INFO_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_INFO, fmt, args)
162 #define MICROSTRAIN_LOG_INFO(...) (void)0
163 #define MICROSTRAIN_LOG_INFO_V(fmt, args) (void)0
171 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_DEBUG
172 #define MICROSTRAIN_LOG_DEBUG(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_DEBUG, __VA_ARGS__)
173 #define MICROSTRAIN_LOG_DEBUG_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_DEBUG, fmt, args)
175 #define MICROSTRAIN_LOG_DEBUG(...) (void)0
176 #define MICROSTRAIN_LOG_DEBUG_V(fmt, args) (void)0
184 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_TRACE
185 #define MICROSTRAIN_LOG_TRACE(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_TRACE, __VA_ARGS__)
186 #define MICROSTRAIN_LOG_TRACE_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_TRACE, fmt, args)
188 #define MICROSTRAIN_LOG_TRACE(...) (void)0
189 #define MICROSTRAIN_LOG_TRACE_V(fmt, args) (void)0
195 #if MICROSTRAIN_ENABLE_LOGGING
196 #define MICROSTRAIN_LOG_BYTES(level, msg, data, length) microstrain_log_bytes(level, msg, data, length)
198 #define MICROSTRAIN_LOG_BYTES(level, msg, data, length) (void)0
207 #if MICROSTRAIN_LOGGING_MAX_LEVEL >= MICROSTRAIN_LOG_LEVEL_TRACE
208 #define MICROSTRAIN_LOG_BYTES_TRACE(msg, data, length) microstrain_log_bytes(MICROSTRAIN_LOG_LEVEL_TRACE, msg, data, length)
210 #define MICROSTRAIN_LOG_BYTES_TRACE(msg, data, length) (void)0
220 #define MICROSTRAIN_LOG_ERROR_WITH_ERRNO(msg) MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", errno, strerror(errno))
230 #define MICROSTRAIN_LOG_ERROR_WITH_ERRNO_EX(msg, ...) MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", __VA_ARGS__, errno, strerror(errno))
@ MICROSTRAIN_LOG_LEVEL_WARN
Warning logs are logged when something concerning happens that may or not be a mistake.
Definition: logging.h:46
void microstrain_log_bytes(const microstrain_log_level level, const char *msg, const uint8_t *data, size_t length)
Print bytes in hex to the log.
Definition: logging.c:136
@ MICROSTRAIN_LOG_LEVEL_INFO
Info logs are logged when some general info needs to be conveyed to the user.
Definition: logging.h:47
void microstrain_logging_log(const microstrain_log_level level, const char *fmt,...)
Internal log function called by logging macros. Call MICROSTRAIN_LOG_* macros instead of using this f...
Definition: logging.c:88
microstrain_log_callback microstrain_logging_callback(void)
Gets the currently active logging callback.
Definition: logging.c:43
microstrain_log_level
Logging level enum.
Definition: logging.h:41
@ MICROSTRAIN_LOG_LEVEL_ERROR
Error logs are logged when an error occurs.
Definition: logging.h:45
void(* microstrain_log_callback)(void *user, const microstrain_log_level level, const char *fmt, va_list args)
Callback function typedef for custom logging behavior.
Definition: logging.h:60
const char * microstrain_logging_level_name(const microstrain_log_level level)
Returns a string representing the given log level.
Definition: logging.c:104
void * microstrain_logging_user_data(void)
Gets the currently active logging user data.
Definition: logging.c:63
microstrain_log_level microstrain_logging_level(void)
Gets the currently active logging level.
Definition: logging.c:53
@ MICROSTRAIN_LOG_LEVEL_OFF
Signifies that the log is turned off.
Definition: logging.h:43
@ MICROSTRAIN_LOG_LEVEL_FATAL
Fatal logs are logged when an unrecoverable error occurs.
Definition: logging.h:44
@ MICROSTRAIN_LOG_LEVEL_TRACE
Trace logs are logged in similar cases to debug logs but can be logged in tight loops.
Definition: logging.h:49
void microstrain_logging_init(const microstrain_log_callback callback, const microstrain_log_level level, void *user)
Initializes the logger with a callback and user data. Call MICROSTRAIN_LOG_INIT instead of using this...
Definition: logging.c:31
@ MICROSTRAIN_LOG_LEVEL_DEBUG
Debug logs are logged for debug purposes.
Definition: logging.h:48
void microstrain_logging_log_v(const microstrain_log_level level, const char *fmt, va_list args)
Internal log function called by variadic logging macros. Call MICROSTRAIN_LOG_*_V macros instead of u...
Definition: logging.c:74