@@ -25,32 +25,35 @@ void LogV(const char * module, uint8_t category, const char * msg, va_list v)
25
25
snprintf (tag, sizeof (tag), " chip[%s]" , module);
26
26
tag[sizeof (tag) - 1 ] = 0 ;
27
27
28
+ // We intentionally added the printf statements to ensure we could apply colors to logs redirected to the console.
29
+ // The printf statements are not bypassing the log level, rather, they are intentionally designed to print the
30
+ // initial and later parts of the log.
28
31
switch (category)
29
32
{
30
33
case kLogCategory_Error : {
31
34
{
32
- esp_log_write (ESP_LOG_ERROR, tag, LOG_COLOR_E " E (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
35
+ printf ( LOG_COLOR_E " E (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
33
36
esp_log_writev (ESP_LOG_ERROR, tag, msg, v);
34
- esp_log_write (ESP_LOG_ERROR, tag, LOG_RESET_COLOR " \n " );
37
+ printf ( LOG_RESET_COLOR " \n " );
35
38
}
36
39
}
37
40
break ;
38
41
39
42
case kLogCategory_Progress :
40
43
default : {
41
44
{
42
- esp_log_write (ESP_LOG_INFO, tag, LOG_COLOR_I " I (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
45
+ printf ( LOG_COLOR_I " I (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
43
46
esp_log_writev (ESP_LOG_INFO, tag, msg, v);
44
- esp_log_write (ESP_LOG_INFO, tag, LOG_RESET_COLOR " \n " );
47
+ printf ( LOG_RESET_COLOR " \n " );
45
48
}
46
49
}
47
50
break ;
48
51
49
52
case kLogCategory_Detail : {
50
53
{
51
- esp_log_write (ESP_LOG_DEBUG, tag, LOG_COLOR_D " D (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
54
+ printf ( LOG_COLOR_D " D (%" PRIu32 " ) %s: " , esp_log_timestamp (), tag);
52
55
esp_log_writev (ESP_LOG_DEBUG, tag, msg, v);
53
- esp_log_write (ESP_LOG_DEBUG, tag, LOG_RESET_COLOR " \n " );
56
+ printf ( LOG_RESET_COLOR " \n " );
54
57
}
55
58
}
56
59
break ;
0 commit comments