随笔 - 2649  文章 - 2452  评论 - 0  阅读 - 81720

Logging

Logging

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

Log level

To enable logging, set LV_USE_LOG 1 in lv_conf.h and set LV_LOG_LEVEL to one of the following values:

  • LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
  • LV_LOG_LEVEL_INFO Log important events
  • LV_LOG_LEVEL_WARN Log if something unwanted happened but didn’t cause a problem
  • LV_LOG_LEVEL_ERROR Only critical issues, where the system may fail
  • LV_LOG_LEVEL_USER Only user messages
  • LV_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 LV_LOG_LEVEL_WARN, errors will be also logged.

Printing logs

Logging with printf

If your system supports printf, you just need to enable LV_LOG_PRINTF in lv_conf.h to send the logs with 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 lv_log_register_print_cb().

For example:

void my_log_cb(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) functions.

posted on   AtlasLapetos  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示