Skip to content

Latest commit

 

History

History
executable file
·
159 lines (99 loc) · 3.88 KB

log.rst

File metadata and controls

executable file
·
159 lines (99 loc) · 3.88 KB

Logging(日志)

显示原文

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


LVGL 有内置的 Log 模块来通知用户库中发生的事情。

Log level(日志等级)

显示原文

To enable logging, set :cLV_USE_LOG in lv_conf.h and set :cLV_LOG_LEVEL to one of the following values:

  • :cLV_LOG_LEVEL_TRACE: A lot of logs to give detailed information
  • :cLV_LOG_LEVEL_INFO: Log important events
  • :cLV_LOG_LEVEL_WARN: Log if something unwanted happened but didn't cause a problem
  • :cLV_LOG_LEVEL_ERROR: Only critical issues, where the system may fail
  • :cLV_LOG_LEVEL_USER: Only user messages
  • :cLV_LOG_LEVEL_NONE: Do not log anything

The events which have a higher level than the set log level will be logged too. E.g. if you :cLV_LOG_LEVEL_WARN, errors will be also logged.


要启用日志记录,请在 lv_conf.h 中设置 :cLV_USE_LOG 并将 :cLV_LOG_LEVEL 设置为以下值之一:

  • :cLV_LOG_LEVEL_TRACE: 大量日志提供详细信息
  • :cLV_LOG_LEVEL_INFO: 记录重要事件
  • :cLV_LOG_LEVEL_WARN: 记录是否发生了不想要的事情但没有引起问题
  • :cLV_LOG_LEVEL_ERROR: 只有关键问题,系统可能会失败
  • :cLV_LOG_LEVEL_USER: 仅用户消息
  • :cLV_LOG_LEVEL_NONE: 不记录任何内容

级别高于设置的日志级别的事件也将被记录。例如。如果你 :cLV_LOG_LEVEL_WARN,错误也会被记录。

Printing logs(打印日志)

Logging with printf(使用 printf 记录)

显示原文

If your system supports printf, you just need to enable :cLV_LOG_PRINTF in lv_conf.h to send the logs with printf.


如果你的系统支持 printf,你只需要在 lv_conf.h 中启用 :cLV_LOG_PRINTF 就可以发送带有 printf 的日志。

Custom log function(自定义日志功能)

显示原文

If you can't use printf or want to use a custom function to log, you can register a "logger" callback with :cpplv_log_register_print_cb.

For example:


如果你不能使用 printf 或者想使用自定义函数来记录日志,你可以使用 :cpplv_log_register_print_cb 注册一个“记录器”回调。

例如:

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);

Add logs(添加日志)

显示原文

You can also use the log module via the LV_LOG_TRACE/INFO/WARN/ERROR/USER(text) or LV_LOG(text) functions. Here:

  • LV_LOG_TRACE/INFO/WARN/ERROR/USER(text) append following information to your text
  • Log Level
  • __FILE__
  • __LINE__
  • __func__
  • LV_LOG(text) is similar to LV_LOG_USER but has no extra information attached.

您还可以通过 LV_LOG_TRACE/INFO/WARN/ERROR/USER(text)LV_LOG(text) 函数使用日志模块。这里:

  • LV_LOG_TRACE/INFO/WARN/ERROR/USER(text) append following information to your text
  • Log Level
  • __FILE__
  • __LINE__
  • __func__
  • LV_LOG(text) is similar to LV_LOG_USER but has no extra information attached.

API