Logging

LVGL has a built-in Logging module to inform the user about what is happening in the library.

Configuring Logging

Log Level

To enable logging, set LV_USE_LOG in lv_conf.h to a non-zero value and set LV_LOG_LEVEL to one of the following values. They are prioritized as follows (from most to least verbose):

When you set LV_LOG_LEVEL to a certain level, only messages with that level or higher priority (less verbose) will be logged.

Example: you set LV_LOG_LEVEL to LV_LOG_LEVEL_WARN, then LV_LOG_LEVEL_WARN, LV_LOG_LEVEL_ERROR and LV_LOG_LEVEL_USER messages will be logged.

Log Output

If your system supports printf, you just need to enable LV_LOG_PRINTF in lv_conf.h to output log messages with printf.

If you can't use printf or want to use a custom function to log, you can register a "logging" function with lv_log_register_print_cb().

For example:

void my_log_cb(lv_log_level_t level, const char * buf)
{
  serial_send(buf, strlen(buf));
}

...


lv_log_register_print_cb(my_log_cb);

Using Logging

You use the log module via the following macros:

  • LV_LOG_TRACE(text)

  • LV_LOG_INFO(text)

  • LV_LOG_WARN(text)

  • LV_LOG_ERROR(text)

  • LV_LOG_USER(text)

  • LV_LOG(text)

The first 5 macros append the following information to your text:

  • Log Level name ("Trace", "Info", "Warn", "Error", "User")

  • __FILE__

  • __LINE__

  • __func__

LV_LOG(text) is similar to LV_LOG_USER but has no extra information added.

API

lv_log.h