11#include <freertos/FreeRTOS.h>
16 explicit Logger() =
default;
19 QueueHandle_t queue_handle =
nullptr;
20 bool use_queue =
false;
38 static Logger _instance;
50 void custom_log(esp_log_level_t level,
const char* tag,
const char* format, ...) const __attribute__((format(printf, 4, 5)));
79#define LOGV(format, ...) do { \
80 if constexpr (Flags::LOWEST_LOG_LEVEL >= ESP_LOG_VERBOSE) { \
81 if constexpr (Flags::ENABLED_VERBOSE_LOG_SOURCES & LOG_SOURCE) { \
82 Logger::get_instance().custom_log(ESP_LOG_VERBOSE, TAG, format, ##__VA_ARGS__); \
94#define LOGD(format, ...) do { \
95 if constexpr (Flags::LOWEST_LOG_LEVEL >= ESP_LOG_DEBUG) { \
96 Logger::get_instance().custom_log(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__); \
107#define LOGI(format, ...) do { \
108 if constexpr (Flags::LOWEST_LOG_LEVEL >= ESP_LOG_INFO) { \
109 Logger::get_instance().custom_log(ESP_LOG_INFO, TAG, format, ##__VA_ARGS__); \
120#define LOGW(format, ...) do { \
121 if constexpr (Flags::LOWEST_LOG_LEVEL >= ESP_LOG_WARN) { \
122 Logger::get_instance().custom_log(ESP_LOG_WARN, TAG, format, ##__VA_ARGS__); \
133#define LOGE(format, ...) do { \
134 if constexpr (Flags::LOWEST_LOG_LEVEL >= ESP_LOG_ERROR) { \
135 Logger::get_instance().custom_log(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__); \
void custom_log(esp_log_level_t level, const char *tag, const char *format,...) const __attribute__((format(printf
Either directly invokes render_to_console (real mode) or sends to the queue (queue mode).
Definition logger.cpp:40
static Logger & get_instance()
Returns a reference to the static logger instance.
Definition logger.h:37
void switch_to_queue_logging(QueueHandle_t log_queue_handle)
Switches the logger's mode to queue logging.
Definition logger.cpp:74
void void print_linefeed() const
Prints a \n in the currently selected mode.
Definition logger.cpp:63
void process_log_queue() const
Processes all entries in the log queue.
Definition logger.cpp:79
bool is_linefeed
Definition logger.h:27
char * message
Definition logger.h:26
const char * tag
Definition logger.h:25
esp_log_level_t level
Definition logger.h:24