4 #ifndef __M5_Log_Class_H__
5 #define __M5_Log_Class_H__
9 #if !defined ( M5UNIFIED_PC_BUILD )
19 #ifndef M5UNIFIED_LOG_FORMAT
20 #define M5UNIFIED_LOG_FORMAT(letter, format) "[%6u][" #letter "][%s:%u] %s(): " format, m5gfx::millis(), m5::Log_Class::pathToFileName(__FILE__), __LINE__, __FUNCTION__
24 #define M5_LOGE(format, ...) M5.Log(ESP_LOG_ERROR , M5UNIFIED_LOG_FORMAT(E, format), ##__VA_ARGS__)
27 #define M5_LOGW(format, ...) M5.Log(ESP_LOG_WARN , M5UNIFIED_LOG_FORMAT(W, format), ##__VA_ARGS__)
30 #define M5_LOGI(format, ...) M5.Log(ESP_LOG_INFO , M5UNIFIED_LOG_FORMAT(I, format), ##__VA_ARGS__)
33 #define M5_LOGD(format, ...) M5.Log(ESP_LOG_DEBUG , M5UNIFIED_LOG_FORMAT(D, format), ##__VA_ARGS__)
36 #define M5_LOGV(format, ...) M5.Log(ESP_LOG_VERBOSE, M5UNIFIED_LOG_FORMAT(V, format), ##__VA_ARGS__)
52 void operator() (esp_log_level_t level,
const char* format, ...);
56 void printf(
const char* format, ...);
60 void print(
const char*
string) {
return printf(
"%s",
string); }
87 void setCallback(std::function<
void(esp_log_level_t log_level,
bool use_color,
const char* log_text)>
function) { _callback =
function; };
101 M5GFX* _display =
nullptr;
103 static constexpr
const char str_crlf[3] =
"\r\n";
104 static constexpr
const char *str_lf = &str_crlf[1];
106 void output(esp_log_level_t level,
bool suffix,
const char* __restrict format, va_list arg);
107 void update_level(
void);
109 std::function<void(esp_log_level_t log_level,
bool use_color,
const char* log_text)> _callback;
111 #if defined ( CORE_DEBUG_LEVEL )
112 esp_log_level_t _level_maximum = (esp_log_level_t)CORE_DEBUG_LEVEL;
113 #elif defined ( CONFIG_LOG_DEFAULT_LEVEL )
114 esp_log_level_t _level_maximum = (esp_log_level_t)CONFIG_LOG_DEFAULT_LEVEL;
116 esp_log_level_t _level_maximum = esp_log_level_t::ESP_LOG_VERBOSE;
118 esp_log_level_t _log_level[
log_target_max] = { _level_maximum, _level_maximum, _level_maximum };
120 const char* _suffix[
log_target_max] = { str_lf, str_lf, str_crlf };
void setDisplay(M5GFX *target)
void setLogLevel(log_target_t target, esp_log_level_t level)
Set log level.
esp_log_level_t getLogLevel(log_target_t target) const
Get log level for serial output.
void println(const char *string)
void setEnableColor(log_target_t target, bool enable)
Set whether or not to change the color for each log level.
bool getEnableColor(log_target_t target) const
Get whether or not to change the color for each log level.
void print(const char *string)
void operator()(esp_log_level_t level, const char *format,...)
Output log.
void setSuffix(log_target_t target, const char *suffix)
Set the text to be added to the end of the log.
static const char * pathToFileName(const char *path)
not for use.
void printf(const char *format,...)
void setDisplay(M5GFX &target)
void setCallback(std::function< void(esp_log_level_t log_level, bool use_color, const char *log_text)> function)