mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-02 17:47:28 +08:00
feat(log) add the elapsed time sine the last log in the message
This commit is contained in:
+4
-2
@@ -67,6 +67,8 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
|||||||
{
|
{
|
||||||
if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/
|
if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/
|
||||||
|
|
||||||
|
static uint32_t last_log_time = 0;
|
||||||
|
|
||||||
if(level >= LV_LOG_LEVEL) {
|
if(level >= LV_LOG_LEVEL) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
@@ -86,8 +88,8 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
|||||||
char buf[512];
|
char buf[512];
|
||||||
uint32_t t = lv_tick_get();
|
uint32_t t = lv_tick_get();
|
||||||
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"};
|
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"};
|
||||||
lv_snprintf(buf, sizeof(buf), "[%s]\t(%d.%03d)\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, func, msg, &file[p], line);
|
lv_snprintf(buf, sizeof(buf), "[%s]\t(%d.%03d, +%d)\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, t - last_log_time, func, msg, &file[p], line);
|
||||||
|
last_log_time = t;
|
||||||
lv_log(buf);
|
lv_log(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user