feat(log): add log level parameters to custom_print_cb (#3826)

Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech 2022-11-24 20:54:15 +08:00 committed by GitHub
parent e7da3b247e
commit 1c2dc983b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ If you can't use `printf` or want to use a custom function to log, you can regis
For example:
```c
void my_log_cb(const char * buf)
void my_log_cb(lv_log_level_t level, const char * buf)
{
serial_send(buf, strlen(buf));
}

View File

@ -108,7 +108,7 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
lv_vsnprintf(msg, sizeof(msg), format, args);
lv_snprintf(buf, sizeof(buf), "[%s]" LOG_TIMESTAMP_FMT " %s: %s \t(in %s line #%d)\n",
lvl_prefix[level], LOG_TIMESTAMP_EXPR func, msg, &file[p], line);
custom_print_cb(buf);
custom_print_cb(level, buf);
}
#endif
@ -132,7 +132,7 @@ void lv_log(const char * format, ...)
if(custom_print_cb) {
char buf[512];
lv_vsnprintf(buf, sizeof(buf), format, args);
custom_print_cb(buf);
custom_print_cb(LV_LOG_LEVEL_USER, buf);
}
#endif

View File

@ -49,7 +49,7 @@ typedef int8_t lv_log_level_t;
/**
* Log print function. Receives a string buffer to print".
*/
typedef void (*lv_log_print_g_cb_t)(const char * buf);
typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char * buf);
/**********************
* GLOBAL PROTOTYPES