feat(log) add the elapsed time sine the last log in the message

This commit is contained in:
Gabor Kiss-Vamosi
2021-05-07 15:28:40 +02:00
parent 3b7bbddb09
commit 77b098db9d

View File

@@ -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*/
static uint32_t last_log_time = 0;
if(level >= LV_LOG_LEVEL) {
va_list args;
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];
uint32_t t = lv_tick_get();
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);
}
}