MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Macros | Typedefs | Functions
MicroStrain Logging [C]

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_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_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_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_INFO(...)   (void)0
 Helper macro used to log data inside the MicroStrain SDK at info level. More...
 
#define MICROSTRAIN_LOG_DEBUG(...)   (void)0
 Helper macro used to log data inside the MicroStrain SDK at debug level. More...
 
#define MICROSTRAIN_LOG_TRACE(...)   (void)0
 Helper macro used to log data inside the MicroStrain SDK at trace level. More...
 

Typedefs

typedef uint8_t microstrain_log_level
 Logging level enum. More...
 
typedef void(* microstrain_log_callback) (void *user, microstrain_log_level level, const char *fmt, va_list args)
 Callback function typedef for custom logging behavior. More...
 

Functions

void microstrain_logging_init (microstrain_log_callback callback, 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 (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...
 

Detailed Description

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

Macro Definition Documentation

◆ MICROSTRAIN_LOG_DEBUG

#define MICROSTRAIN_LOG_DEBUG (   ...)    (void)0

Helper macro used to log data inside the MicroStrain SDK at debug level.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_ERROR

#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.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_FATAL

#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.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_INFO

#define MICROSTRAIN_LOG_INFO (   ...)    (void)0

Helper macro used to log data inside the MicroStrain SDK at info level.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_INIT

#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.

Parameters
callbackThe callback to execute when there is data to log
levelThe level that the MicroStrain SDK should log at
userUser data that will be passed to the callback every time it is excuted

◆ MICROSTRAIN_LOG_LEVEL_DEBUG

#define MICROSTRAIN_LOG_LEVEL_DEBUG   5

Debug logs are logged for debug purposes.

◆ MICROSTRAIN_LOG_LEVEL_ERROR

#define MICROSTRAIN_LOG_LEVEL_ERROR   2

Error logs are logged when an error occurs.

◆ MICROSTRAIN_LOG_LEVEL_FATAL

#define MICROSTRAIN_LOG_LEVEL_FATAL   1

Fatal logs are logged when an unrecoverable error occurs.

◆ MICROSTRAIN_LOG_LEVEL_INFO

#define MICROSTRAIN_LOG_LEVEL_INFO   4

Info logs are logged when some general info needs to be conveyed to the user.

◆ MICROSTRAIN_LOG_LEVEL_OFF

#define MICROSTRAIN_LOG_LEVEL_OFF   0

Signifies that the log is turned off.

◆ MICROSTRAIN_LOG_LEVEL_TRACE

#define MICROSTRAIN_LOG_LEVEL_TRACE   6

Trace logs are logged in similar cases to debug logs but can be logged in tight loops.

◆ MICROSTRAIN_LOG_LEVEL_WARN

#define MICROSTRAIN_LOG_LEVEL_WARN   3

Warning logs are logged when something concerning happens that may or not be a mistake.

◆ MICROSTRAIN_LOG_LOG

#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.

Parameters
levelThe log level that this log should be logged at
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_TRACE

#define MICROSTRAIN_LOG_TRACE (   ...)    (void)0

Helper macro used to log data inside the MicroStrain SDK at trace level.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOG_WARN

#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.

Parameters
contextContext of what called this function. Could be a mip device, serial connection, etc.
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ MICROSTRAIN_LOGGING_MAX_LEVEL

#define MICROSTRAIN_LOGGING_MAX_LEVEL   MICROSTRAIN_LOG_LEVEL_WARN

Typedef Documentation

◆ microstrain_log_callback

typedef void(* microstrain_log_callback) (void *user, microstrain_log_level level, const char *fmt, va_list args)

Callback function typedef for custom logging behavior.

Parameters
levelThe log level that this log should be logged at
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ microstrain_log_level

typedef uint8_t microstrain_log_level

Logging level enum.

Function Documentation

◆ microstrain_logging_callback()

microstrain_log_callback microstrain_logging_callback ( void  )

Gets the currently active logging callback.

Returns
The currently active logging callback

◆ microstrain_logging_init()

void microstrain_logging_init ( microstrain_log_callback  callback,
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.

Parameters
callbackThe callback to execute when there is data to log
levelThe level that the MicroStrain SDK should log at
userUser data that will be passed to the callback every time it is excuted

◆ microstrain_logging_level()

microstrain_log_level microstrain_logging_level ( void  )

Gets the currently active logging level.

Returns
The currently active logging level

◆ microstrain_logging_log()

void microstrain_logging_log ( microstrain_log_level  level,
const char *  fmt,
  ... 
)

Internal log function called by logging macros. Call MICROSTRAIN_LOG_* macros instead of using this function directly.

Parameters
levelThe log level that this log should be logged at
fmtprintf style format string
...Variadic args used to populate the fmt string

◆ microstrain_logging_user_data()

void* microstrain_logging_user_data ( void  )

Gets the currently active logging user data.

Returns
The currently active logging user data