Soletta machine learning
Machine learning for IoT devices
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
Macros | Typedefs | Enumerations | Functions
Log

These functions and data types are responsible for logging the SML events. More...

Macros

#define sml_critical(...)   sml_log_print(SML_LOG_LEVEL_CRITICAL, __VA_ARGS__)
 Syntactic sugar to sml_log_print(SML_LOG_LEVEL_CRITICAL, "critical message") More...
 
#define sml_debug(...)   sml_log_print(SML_LOG_LEVEL_DEBUG, __VA_ARGS__)
 Syntactic sugar to sml_log_print(SML_LOG_LEVEL_DEBUG, "debug message") More...
 
#define sml_error(...)   sml_log_print(SML_LOG_LEVEL_ERROR, __VA_ARGS__)
 Syntactic sugar to sml_log_print(SML_LOG_LEVEL_ERROR, "error message") More...
 
#define sml_info(...)   sml_log_print(SML_LOG_LEVEL_INFO, __VA_ARGS__)
 Syntactic sugar to sml_log_print(SML_LOG_LEVEL_INFO, "info message") More...
 
#define sml_warning(...)   sml_log_print(SML_LOG_LEVEL_WARNING, __VA_ARGS__)
 Syntactic sugar to sml_log_print(SML_LOG_LEVEL_WARNING, "warning message") More...
 

Typedefs

typedef void(* sml_log_handler_cb )(enum sml_log_level level, const char *msg, void *data)
 Log handler callback. More...
 

Enumerations

enum  sml_log_level {
  SML_LOG_LEVEL_DEBUG = 1 << 0, SML_LOG_LEVEL_INFO = 1 << 1, SML_LOG_LEVEL_WARNING = 1 << 2, SML_LOG_LEVEL_ERROR = 1 << 3,
  SML_LOG_LEVEL_CRITICAL = 1 << 4, SML_LOG_LEVEL_ALL = (SML_LOG_LEVEL_DEBUG | SML_LOG_LEVEL_INFO | SML_LOG_LEVEL_WARNING | SML_LOG_LEVEL_ERROR | SML_LOG_LEVEL_CRITICAL)
}
 Log level types. More...
 

Functions

void sml_log_print (enum sml_log_level level, const char *format,...)
 Prints a message with a desired log level. More...
 
void sml_log_set_log_handler (enum sml_log_level levels, sml_log_handler_cb cb, void *data)
 Set a log handler. More...
 

Detailed Description

These functions and data types are responsible for logging the SML events.

Macro Definition Documentation

#define sml_critical (   ...)    sml_log_print(SML_LOG_LEVEL_CRITICAL, __VA_ARGS__)

Syntactic sugar to sml_log_print(SML_LOG_LEVEL_CRITICAL, "critical message")

Parameters
...A formatted message
See Also
sml_log_print
#define sml_debug (   ...)    sml_log_print(SML_LOG_LEVEL_DEBUG, __VA_ARGS__)

Syntactic sugar to sml_log_print(SML_LOG_LEVEL_DEBUG, "debug message")

Parameters
...A formatted message
See Also
sml_log_print
#define sml_error (   ...)    sml_log_print(SML_LOG_LEVEL_ERROR, __VA_ARGS__)

Syntactic sugar to sml_log_print(SML_LOG_LEVEL_ERROR, "error message")

Parameters
...A formatted message
See Also
sml_log_print
#define sml_info (   ...)    sml_log_print(SML_LOG_LEVEL_INFO, __VA_ARGS__)

Syntactic sugar to sml_log_print(SML_LOG_LEVEL_INFO, "info message")

Parameters
...A formatted message
See Also
sml_log_print
#define sml_warning (   ...)    sml_log_print(SML_LOG_LEVEL_WARNING, __VA_ARGS__)

Syntactic sugar to sml_log_print(SML_LOG_LEVEL_WARNING, "warning message")

Parameters
...A formatted message
See Also
sml_log_print

Typedef Documentation

typedef void(* sml_log_handler_cb)(enum sml_log_level level, const char *msg, void *data)

Log handler callback.

This function is responsible for logging the message. It is called every time sml_log_print is called.

Parameters
levelThe message log level.
msgThe message itself.
dataUser data that was set with sml_log_set_log_handler.
See Also
sml_log_set_log_handler

Enumeration Type Documentation

Log level types.

Enumerator
SML_LOG_LEVEL_DEBUG 

Show debug messages. The debug messages will not be logged with SML is compiled in Release mode.

SML_LOG_LEVEL_INFO 

Show info messages.

SML_LOG_LEVEL_WARNING 

Show warning messages.

SML_LOG_LEVEL_ERROR 

Show error messages.

SML_LOG_LEVEL_CRITICAL 

Show critical messages.

SML_LOG_LEVEL_ALL 

Show all messages.

Function Documentation

void sml_log_print ( enum sml_log_level  level,
const char *  format,
  ... 
)

Prints a message with a desired log level.

Parameters
levelThe desired log level.
formatA formatted string.
...Contents of the formatted string.
void sml_log_set_log_handler ( enum sml_log_level  levels,
sml_log_handler_cb  cb,
void *  data 
)

Set a log handler.

This function is useful if one wants to log SML events in files or do not want to log SML_LOG_LEVEL_WARNING messages, for example. SML provides a default sml_log_handler_cb that is automatically set at startup, the log level is set to SML_LOG_LEVEL_ALL and all messages will be logged at stdout.

Parameters
levelsThe log levels that will be captured.
cbA user defined callback to a log handler.
dataUser data to cb.
See Also
sml_log_handler_cb