29 lines
1.2 KiB
C
29 lines
1.2 KiB
C
/*
|
|
* Host stand-in for ESP-IDF's esp_log.h -- see compat/esp_err.h for why these
|
|
* shims exist. Logs go to stderr so that stdout stays clean for anything the
|
|
* simulator wants to emit as data.
|
|
*/
|
|
#ifndef ESP_LOG_H
|
|
#define ESP_LOG_H
|
|
|
|
#include <stdio.h>
|
|
|
|
/* ANSI colours matched to idf.py monitor, so simulator output reads the same
|
|
* way device output does. */
|
|
#define ESP_LOG_COLOR_E "\033[0;31m"
|
|
#define ESP_LOG_COLOR_W "\033[0;33m"
|
|
#define ESP_LOG_COLOR_I "\033[0;32m"
|
|
#define ESP_LOG_COLOR_D "\033[0;36m"
|
|
#define ESP_LOG_RESET "\033[0m"
|
|
|
|
#define ESP_LOG_LEVEL_LOCAL(colour, letter, tag, fmt, ...) \
|
|
fprintf(stderr, colour letter " (sim) %s: " fmt ESP_LOG_RESET "\n", tag, ##__VA_ARGS__)
|
|
|
|
#define ESP_LOGE(tag, fmt, ...) ESP_LOG_LEVEL_LOCAL(ESP_LOG_COLOR_E, "E", tag, fmt, ##__VA_ARGS__)
|
|
#define ESP_LOGW(tag, fmt, ...) ESP_LOG_LEVEL_LOCAL(ESP_LOG_COLOR_W, "W", tag, fmt, ##__VA_ARGS__)
|
|
#define ESP_LOGI(tag, fmt, ...) ESP_LOG_LEVEL_LOCAL(ESP_LOG_COLOR_I, "I", tag, fmt, ##__VA_ARGS__)
|
|
#define ESP_LOGD(tag, fmt, ...) ESP_LOG_LEVEL_LOCAL(ESP_LOG_COLOR_D, "D", tag, fmt, ##__VA_ARGS__)
|
|
#define ESP_LOGV(tag, fmt, ...) ESP_LOG_LEVEL_LOCAL(ESP_LOG_COLOR_D, "V", tag, fmt, ##__VA_ARGS__)
|
|
|
|
#endif
|