mikroSDK Reference Manual
Logger Library

Data Structures

struct  log_t
 LOG context structure. More...
 
struct  log_cfg_t
 LOG init configuration structure. More...
 

Macros

#define LOG_MAP_USB_UART(cfg)   cfg.level = LOG_LEVEL_DEBUG;
 LOG MAP to the USB UART configuration.
 
#define LOG_MAP_MIKROBUS(cfg, mikrobus)   cfg.level = LOG_LEVEL_DEBUG;
 LOG MAP to the MikroBUS configuration.
 
#define LOG_MAP_USB_UART(cfg)
 LOG MAP to the USB UART configuration NOTE If USB_UART_RX and USB_UART_TX are not defined (defined as HAL_PIN_NC) define them manually. Pins are defined as Pxy where:
 
#define LOG_MAP_MIKROBUS(cfg, mikrobus)
 LOG MAP to the MikroBUS configuration.
 

Enumerations

enum  log_level_t {
  LOG_LEVEL_DEBUG = 0x00 , LOG_LEVEL_INFO = 0x01 , LOG_LEVEL_WARNING = 0x02 , LOG_LEVEL_ERROR = 0x03 ,
  LOG_LEVEL_FATAL = 0x04
}
 Log level values.
 
enum  log_level_t {
  LOG_LEVEL_DEBUG = 0x00 , LOG_LEVEL_INFO = 0x01 , LOG_LEVEL_WARNING = 0x02 , LOG_LEVEL_ERROR = 0x03 ,
  LOG_LEVEL_FATAL = 0x04
}
 Log level values.
 

Functions list

void log_init (log_t *log, log_cfg_t *cfg)
 Initializes LOG module.
 
void log_printf (log_t *log, const code char *__generic_ptr f,...)
 Printf function.
 
void log_clear (log_t *log)
 Empty wrapper API.
 
int8_t log_read (log_t *log, uint8_t *rx_data_buf, uint8_t max_len)
 Empty wrapper API.
 
void log_info (log_t *log, const code char *__generic_ptr f,...)
 INFO printf function.
 
void log_error (log_t *log, const code char *__generic_ptr f,...)
 ERROR printf function.
 
void log_fatal (log_t *log, const code char *__generic_ptr f,...)
 FATAL printf function.
 
void log_debug (log_t *log, const code char *__generic_ptr f,...)
 DEBUG printf function.
 
void log_warning (log_t *log, const code char *__generic_ptr f,...)
 WARNING printf function.
 
void log_log (log_t *log, char *prefix, const code char *__generic_ptr f,...)
 Printf function with a variable prefix.
 

Macro Definition Documentation

◆ LOG_MAP_MIKROBUS [1/2]

#define LOG_MAP_MIKROBUS ( cfg,
mikrobus )   cfg.level = LOG_LEVEL_DEBUG;
Note
Build compatibility only, not functional.

◆ LOG_MAP_MIKROBUS [2/2]

#define LOG_MAP_MIKROBUS ( cfg,
mikrobus )
Value:
cfg.rx_pin = MIKROBUS(mikrobus, MIKROBUS_RX); \
cfg.tx_pin = MIKROBUS(mikrobus, MIKROBUS_TX); \
cfg.baud = 115200; \
cfg.level = LOG_LEVEL_DEBUG;

◆ LOG_MAP_USB_UART [1/2]

#define LOG_MAP_USB_UART ( cfg)    cfg.level = LOG_LEVEL_DEBUG;

LOG MAP to the USB UART configuration NOTE If USB_UART_RX and USB_UART_TX are not defined (defined as HAL_PIN_NC) define them manually. Pins are defined as Pxy where:

Note
Build compatibility only, not functional.
  • x represents port name ( A, B, C ... )
  • y represents pin ( 1,2,3...15...31 ) Example: #define USB_UART_RX PA14 #define USB_UART_TX PC0

◆ LOG_MAP_USB_UART [2/2]

#define LOG_MAP_USB_UART ( cfg)
Value:
cfg.rx_pin = USB_UART_RX; \
cfg.tx_pin = USB_UART_TX; \
cfg.baud = 115200; \
cfg.level = LOG_LEVEL_DEBUG;
  • x represents port name ( A, B, C ... )
  • y represents pin ( 1,2,3...15...31 ) Example: #define USB_UART_RX PA14 #define USB_UART_TX PC0

Function Documentation

◆ log_clear()

void log_clear ( log_t * log)

Discards all characters from the output and input buffer.

Note
Build compatibility only, not functional.
Parameters
[in]logLOG context object.
[in]logLOG context object.

◆ log_debug()

void log_debug ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses the prefix [DEBUG] and checks for log level.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses the prefix [DEBUG] and check for log level

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

◆ log_error()

void log_error ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses the prefix [ERROR] and checks for log level.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses the prefix [ERROR] and check for log level

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

◆ log_fatal()

void log_fatal ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses the prefix [FATAL] and checks for log level.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses the prefix [FATAL] and check for log level

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

◆ log_info()

void log_info ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses the prefix [INFO] and checks for log level.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses the prefix [INFO] and check for log level

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

◆ log_init()

void log_init ( log_t * log,
log_cfg_t * cfg )

Initializes LOG driver. This function needs to be called before other driver functions.

Parameters
[in]logLOG context object.
[in]cfgLOG configuration structure.

◆ log_log()

void log_log ( log_t * log,
char * prefix,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses a variable prefix.

Parameters
[in]logLOG context object.
[in]prefixPrefix.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses a variable prefix.

Parameters
[in]logLOG context object.
[in]prefixPrefix.
[in]*fpointer to the string
[in]...Other parameters

◆ log_printf()

void log_printf ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used to print a message on the std_out terminal.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

◆ log_read()

int8_t log_read ( log_t * log,
uint8_t * rx_data_buf,
uint8_t max_len )

Reads at most size bytes of data from the device into buffer.

Note
Build compatibility only, not functional.
Returns
0
Parameters
[in]logLOG context object.
[out]rx_data_bufArray to place read data in.
[in]max_lenMaximal length
Returns
err_t Returns the number of bytes that were actually read, or -1 if an error occurred or no data read.

◆ log_warning()

void log_warning ( log_t * log,
const code char *__generic_ptr f,
... )

This function is used print a message on the std_out terminal. This function uses the prefix [WARNING] and checks for log level.

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters

This function uses to be a print message on the UART. This function uses the prefix [WARNING] and check for log level

Parameters
[in]logLOG context object.
[in]*fpointer to the string
[in]...Other parameters