mikroSDK Reference Manual
Logger Library

Logger Library API reference. More...

Macros

#define ABS(x)   (((x)>0)?(x):-(x))
 Computes the absolute value of its argument x. More...
 
#define LOG_MAP_USB_UART(cfg)
 LOG MAP to the USB UART configuration. More...
 
#define LOG_MAP_MIKROBUS(cfg, mikrobus)
 LOG MAP to the MikroBUS configuration. More...
 

Functions list

void log_init (log_t *log, log_cfg_t *cfg)
 Initializes LOG module. More...
 
void log_printf (log_t *log, const code char *__generic f,...)
 Printf function. More...
 
void log_clear (log_t *log)
 Discards all characters from the output and input buffer. More...
 
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. More...
 
void log_info (log_t *log, const code char *__generic f,...)
 INFO printf function. More...
 
void log_error (log_t *log, const code char *__generic f,...)
 ERROR printf function. More...
 
void log_fatal (log_t *log, const code char *__generic f,...)
 FATAL printf function. More...
 
void log_debug (log_t *log, const code char *__generic f,...)
 DEBUG printf function. More...
 
void log_warning (log_t *log, const code char *__generic f,...)
 WARNING printf function. More...
 
void log_log (log_t *log, char *prefix, const code char *__generic f,...)
 Printf function with a variable prefix. More...
 

Detailed Description

API for configuring and manipulating Graphics library.

Macro Definition Documentation

◆ ABS

#define ABS (   x)    (((x)>0)?(x):-(x))
Parameters
xinput value.
Returns
absolute value of x.

◆ LOG_MAP_USB_UART

#define LOG_MAP_USB_UART (   cfg)
Value:
cfg.rx_pin = USB_UART_RX; \
cfg.tx_pin = USB_UART_TX; \
cfg.baud = 9600; \
cfg.level = LOG_LEVEL_DEBUG;

Computes the absolute value of its argument cfg.

Parameters
cfginput value.
Returns
absolute value of cfg.

◆ LOG_MAP_MIKROBUS

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

Function Documentation

◆ 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]log: LOG context object.
[in]cfg: LOG configuration structure.
Returns
Nothing.

◆ log_printf()

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

This function prints a message on the UART.

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.

◆ log_clear()

void log_clear ( log_t log)

Discards all characters from the output and input buffer.

Parameters
[in]log: LOG context object.
Returns
Nothing.

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

Parameters
[in]log: LOG context object.
[out]rx_data_buf: Array to place read data in.
[in]max_len: Maximal length
Returns
Returns the number of bytes that were actually read, or -1 if an error occurred or no data read.

◆ log_info()

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

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

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.

◆ log_error()

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

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

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.

◆ log_fatal()

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

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

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.
Nothing.

◆ log_debug()

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

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

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.

◆ log_warning()

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

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

Parameters
[in]log: LOG context object.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.

◆ log_log()

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

This function prints a message on the UART. This function uses a variable prefix.

Parameters
[in]log: LOG context object.
[in]prefix: Prefix.
[in]*f: pointer to the string
[in]...: Other parameters
Returns
Nothing.
LOG_LEVEL_DEBUG
Definition: log.h:58