feat(logger): add logging macros for consistent logging across components

This commit is contained in:
HendrikRauh 2026-03-07 21:02:31 +01:00
parent 9a11453fbc
commit a2d51540b7
7 changed files with 77 additions and 33 deletions

View file

@ -0,0 +1,43 @@
/**
* @file logger.h
* @brief Project-wide logging macros based on ESP-IDF's logging library.
*
* This header provides a set of simple logging macros (LOGE, LOGW, LOGI, etc.)
* that wrap the underlying ESP-IDF logging functions (esp_log_e, esp_log_w,
* etc.).
*
* @section usage Usage
* To use these macros, a `LOG_TAG` should be defined before including this
* header. The `LOG_TAG` is a string that identifies the source of the log
* messages, typically the component or file name. If `LOG_TAG` is not defined,
* a default tag "CHAOS" will be used.
*
* @example
* #define LOG_TAG "MY_COMPONENT"
* #include "logger.h"
*
* void my_function() {
* LOGI("This is an informational message.");
* LOGE("This is an error message with a value: %d", 42);
* }
*/
#pragma once
#include "esp_log.h"
#ifndef LOG_TAG
#define LOG_TAG "CHAOS"
#endif
/** @brief Log a message at Error level. */
#define LOGE(...) ESP_LOGE(LOG_TAG, __VA_ARGS__)
/** @brief Log a message at Warning level. */
#define LOGW(...) ESP_LOGW(LOG_TAG, __VA_ARGS__)
/** @brief Log a message at Info level. */
#define LOGI(...) ESP_LOGI(LOG_TAG, __VA_ARGS__)
/** @brief Log a message at Debug level. */
#define LOGD(...) ESP_LOGD(LOG_TAG, __VA_ARGS__)
/** @brief Log a message at Verbose level. */
#define LOGV(...) ESP_LOGV(LOG_TAG, __VA_ARGS__)