feat(log): add log level parameters to custom_print_cb (#3826)
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -25,7 +25,7 @@ If you can't use `printf` or want to use a custom function to log, you can regis
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```c
|
```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));
|
serial_send(buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_vsnprintf(msg, sizeof(msg), format, args);
|
||||||
lv_snprintf(buf, sizeof(buf), "[%s]" LOG_TIMESTAMP_FMT " %s: %s \t(in %s line #%d)\n",
|
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);
|
lvl_prefix[level], LOG_TIMESTAMP_EXPR func, msg, &file[p], line);
|
||||||
custom_print_cb(buf);
|
custom_print_cb(level, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ void lv_log(const char * format, ...)
|
|||||||
if(custom_print_cb) {
|
if(custom_print_cb) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
lv_vsnprintf(buf, sizeof(buf), format, args);
|
lv_vsnprintf(buf, sizeof(buf), format, args);
|
||||||
custom_print_cb(buf);
|
custom_print_cb(LV_LOG_LEVEL_USER, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ typedef int8_t lv_log_level_t;
|
|||||||
/**
|
/**
|
||||||
* Log print function. Receives a string buffer to print".
|
* 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
|
* GLOBAL PROTOTYPES
|
||||||
|
|||||||
Reference in New Issue
Block a user