MIP_SDK
v3.0.0-192-g8bd7933
MicroStrain Communications Library for embedded systems
|
High-level C functions for logging information from within the MicroStrain SDK. More...
Macros | |
#define | MICROSTRAIN_LOG_LEVEL_OFF 0 |
Signifies that the log is turned off. More... | |
#define | MICROSTRAIN_LOG_LEVEL_FATAL 1 |
Fatal logs are logged when an unrecoverable error occurs. More... | |
#define | MICROSTRAIN_LOG_LEVEL_ERROR 2 |
Error logs are logged when an error occurs. More... | |
#define | MICROSTRAIN_LOG_LEVEL_WARN 3 |
Warning logs are logged when something concerning happens that may or not be a mistake. More... | |
#define | MICROSTRAIN_LOG_LEVEL_INFO 4 |
Info logs are logged when some general info needs to be conveyed to the user. More... | |
#define | MICROSTRAIN_LOG_LEVEL_DEBUG 5 |
Debug logs are logged for debug purposes. More... | |
#define | MICROSTRAIN_LOG_LEVEL_TRACE 6 |
Trace logs are logged in similar cases to debug logs but can be logged in tight loops. More... | |
#define | MICROSTRAIN_LOG_INIT(callback, level, user) (void)0 |
Helper macro used to initialize the MicroStrain logger. This function does not need to be called unless the user wants logging. More... | |
#define | MICROSTRAIN_LOG_LOG(level, ...) (void)0 |
Helper macro used to log data inside the MicroStrain SDK. Prefer specific log level functions like MICROSTRAIN_LOG_INFO, etc. when possible. More... | |
#define | MICROSTRAIN_LOG_LOG_V(level, fmt, args) (void)0 |
#define | MICROSTRAIN_LOGGING_MAX_LEVEL MICROSTRAIN_LOG_LEVEL_WARN |
#define | MICROSTRAIN_LOG_FATAL(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_FATAL, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at fatal level. More... | |
#define | MICROSTRAIN_LOG_FATAL_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_FATAL, fmt, args) |
#define | MICROSTRAIN_LOG_ERROR(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_ERROR, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at error level. More... | |
#define | MICROSTRAIN_LOG_ERROR_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_ERROR, fmt, args) |
#define | MICROSTRAIN_LOG_WARN(...) MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_WARN, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at warn level. More... | |
#define | MICROSTRAIN_LOG_WARN_V(fmt, args) MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_WARN, fmt, args) |
#define | MICROSTRAIN_LOG_INFO(...) (void)0 |
Helper macro used to log data inside the MicroStrain SDK at info level. More... | |
#define | MICROSTRAIN_LOG_INFO_V(fmt, args) (void)0 |
#define | MICROSTRAIN_LOG_DEBUG(...) (void)0 |
Helper macro used to log data inside the MicroStrain SDK at debug level. More... | |
#define | MICROSTRAIN_LOG_DEBUG_V(fmt, args) (void)0 |
#define | MICROSTRAIN_LOG_TRACE(...) (void)0 |
Helper macro used to log data inside the MicroStrain SDK at trace level. More... | |
#define | MICROSTRAIN_LOG_TRACE_V(fmt, args) (void)0 |
#define | MICROSTRAIN_LOG_ERROR_WITH_ERRNO(msg) MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", errno, strerror(errno)) |
Helper macro used to log an error message from a syscall. More... | |
#define | MICROSTRAIN_LOG_ERROR_WITH_ERRNO_EX(msg, ...) MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", __VA_ARGS__, errno, strerror(errno)) |
Helper macro used to log an error message from a syscall. More... | |
#define | MICROSTRAIN_LOG_BYTES(level, buffer, length, ...) |
Log an array of bytes. More... | |
Typedefs | |
typedef uint8_t | microstrain_log_level |
Logging level enum. More... | |
typedef void(* | microstrain_log_callback) (void *user, const microstrain_log_level level, const char *fmt, va_list args) |
Callback function typedef for custom logging behavior. More... | |
Functions | |
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 function directly. This function does not have to be called unless the user wants logging. More... | |
microstrain_log_callback | microstrain_logging_callback (void) |
Gets the currently active logging callback. More... | |
microstrain_log_level | microstrain_logging_level (void) |
Gets the currently active logging level. More... | |
void * | microstrain_logging_user_data (void) |
Gets the currently active logging user data. More... | |
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 using this function directly. More... | |
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 function directly. More... | |
const char * | microstrain_logging_level_name (const microstrain_log_level level) |
Returns a string representing the given log level. More... | |
High-level C functions for logging information from within the MicroStrain SDK.
This module contains functions that allow the MicroStrain SDK to log information and allows users to override the logging functions
#define MICROSTRAIN_LOG_BYTES | ( | level, | |
buffer, | |||
length, | |||
... | |||
) |
Log an array of bytes.
level | Log level for this message. |
buffer | Pointer to a byte array of type (const char*)/ |
length | Length of buffer. |
... | Arguments corresponding to a printf-style message with optional formatting. The resulting message will be "<message here> XX XX XX XX ...\n" where XX is a pair of hex digits. |
#define MICROSTRAIN_LOG_DEBUG | ( | ... | ) | (void)0 |
Helper macro used to log data inside the MicroStrain SDK at debug level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_DEBUG_V | ( | fmt, | |
args | |||
) | (void)0 |
#define MICROSTRAIN_LOG_ERROR | ( | ... | ) | MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_ERROR, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at error level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_ERROR_V | ( | fmt, | |
args | |||
) | MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_ERROR, fmt, args) |
#define MICROSTRAIN_LOG_ERROR_WITH_ERRNO | ( | msg | ) | MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", errno, strerror(errno)) |
Helper macro used to log an error message from a syscall.
msg | A plain C-string without any printf-style formatters. The resulting log message will be "<message here>: <error-code> <error-description>\n". |
#define MICROSTRAIN_LOG_ERROR_WITH_ERRNO_EX | ( | msg, | |
... | |||
) | MICROSTRAIN_LOG_ERROR(msg ": %d %s\n", __VA_ARGS__, errno, strerror(errno)) |
Helper macro used to log an error message from a syscall.
msg | A plain C-string which includes one or more printf-style formatters. |
... | Arguments corresponding to the format codes in msg. The resulting log message will be "<message here>: <error-code> <error-description>\n". |
#define MICROSTRAIN_LOG_FATAL | ( | ... | ) | MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_FATAL, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at fatal level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_FATAL_V | ( | fmt, | |
args | |||
) | MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_FATAL, fmt, args) |
#define MICROSTRAIN_LOG_INFO | ( | ... | ) | (void)0 |
Helper macro used to log data inside the MicroStrain SDK at info level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_INFO_V | ( | fmt, | |
args | |||
) | (void)0 |
#define MICROSTRAIN_LOG_INIT | ( | callback, | |
level, | |||
user | |||
) | (void)0 |
Helper macro used to initialize the MicroStrain logger. This function does not need to be called unless the user wants logging.
callback | The callback to execute when there is data to log |
level | The level that the MicroStrain SDK should log at |
user | User data that will be passed to the callback every time it is executed |
#define MICROSTRAIN_LOG_LEVEL_DEBUG 5 |
Debug logs are logged for debug purposes.
#define MICROSTRAIN_LOG_LEVEL_ERROR 2 |
Error logs are logged when an error occurs.
#define MICROSTRAIN_LOG_LEVEL_FATAL 1 |
Fatal logs are logged when an unrecoverable error occurs.
#define MICROSTRAIN_LOG_LEVEL_INFO 4 |
Info logs are logged when some general info needs to be conveyed to the user.
#define MICROSTRAIN_LOG_LEVEL_OFF 0 |
Signifies that the log is turned off.
#define MICROSTRAIN_LOG_LEVEL_TRACE 6 |
Trace logs are logged in similar cases to debug logs but can be logged in tight loops.
#define MICROSTRAIN_LOG_LEVEL_WARN 3 |
Warning logs are logged when something concerning happens that may or not be a mistake.
#define MICROSTRAIN_LOG_LOG | ( | level, | |
... | |||
) | (void)0 |
Helper macro used to log data inside the MicroStrain SDK. Prefer specific log level functions like MICROSTRAIN_LOG_INFO, etc. when possible.
user | User data pointer |
level | The log level that this log should be logged at |
fmt | printf style format string |
args | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_LOG_V | ( | level, | |
fmt, | |||
args | |||
) | (void)0 |
#define MICROSTRAIN_LOG_TRACE | ( | ... | ) | (void)0 |
Helper macro used to log data inside the MicroStrain SDK at trace level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_TRACE_V | ( | fmt, | |
args | |||
) | (void)0 |
#define MICROSTRAIN_LOG_WARN | ( | ... | ) | MICROSTRAIN_LOG_LOG(MICROSTRAIN_LOG_LEVEL_WARN, __VA_ARGS__) |
Helper macro used to log data inside the MicroStrain SDK at warn level.
context | Context of what called this function. Could be a mip device, serial connection, etc. |
fmt | printf style format string |
... | Variadic args used to populate the fmt string |
#define MICROSTRAIN_LOG_WARN_V | ( | fmt, | |
args | |||
) | MICROSTRAIN_LOG_LOG_V(MICROSTRAIN_LOG_LEVEL_WARN, fmt, args) |
#define MICROSTRAIN_LOGGING_MAX_LEVEL MICROSTRAIN_LOG_LEVEL_WARN |
typedef void(* microstrain_log_callback) (void *user, const microstrain_log_level level, const char *fmt, va_list args) |
Callback function typedef for custom logging behavior.
user | User data pointer |
level | The log level that this log should be logged at |
fmt | printf style format string |
args | Variadic args used to populate the fmt string |
typedef uint8_t microstrain_log_level |
Logging level enum.
microstrain_log_callback microstrain_logging_callback | ( | void | ) |
Gets the currently active logging callback.
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 function directly. This function does not have to be called unless the user wants logging.
callback | The callback to execute when there is data to log |
level | The level that the MicroStrain SDK should log at |
user | User data that will be passed to the callback every time it is executed |
microstrain_log_level microstrain_logging_level | ( | void | ) |
Gets the currently active logging level.
const char* microstrain_logging_level_name | ( | const microstrain_log_level | level | ) |
Returns a string representing the given log level.
level | The returned string is statically-allocated and shall not be freed nor modified. The strings are padded to a uniform length for consistent alignment in log files. |
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 function directly.
user | User data pointer |
level | The log level that this log should be logged at |
fmt | printf style format string |
args | Variadic args used to populate the fmt string |
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 using this function directly.
user | User data pointer |
level | The log level that this log should be logged at |
fmt | printf style format string |
args | Variadic args used to populate the fmt string |
void* microstrain_logging_user_data | ( | void | ) |
Gets the currently active logging user data.