|
esp_iot_framework
v0.1.0-alpha
© 2026 AmakeSasha, distributed under a license Apache-2.0
|
Simple console logging macros with config level control. More...
Macros | |
| #define | EIF_TAG_WITH_UNUSED static const char* const TAG __attribute__((unused)) = |
| Helper to define a local logging 'TAG' identifier. More... | |
| #define | EIF_PRINT(m_macro, m_format, ...) m_macro(TAG, "%s:%d (%s) " m_format, __FILE__, __LINE__, __func__, ##__VA_ARGS__) |
| Low-level macro to format and output messages to the ESP log system. More... | |
| #define | EIF_SHOW_ESP_ERR_T(m_result, m_expr, m_format, ...) |
| Unconditionally executes an expression and logs warning details on failure. More... | |
Logging Severity Levels | |
| #define | EIF_LOG_LEVEL_E 1 |
| Error log level severity. | |
| #define | EIF_LOG_LEVEL_W 2 |
| Warning log level severity. | |
| #define | EIF_LOG_LEVEL_I 3 |
| Informational log level severity. | |
| #define | EIF_LOG_LEVEL_D 4 |
| Debug log level severity. | |
Application Logging Interface | ||||
Main logging macros with global compile-time filtering. Use these macros to print logs to the console. Which logs actually get compiled into the firmware depends on the For example: if When a log level is ignored, its macro turns into an empty
Example of use: #include <esp_log.h>
#include <esp_iot_framework_core_macros.h>
void check_system_health(float voltage, bool is_connected) {
if (voltage < 3.2f) {
EIF_LOG_E("Voltage critical: %.2fV", voltage);
} else if (!is_connected) {
EIF_LOG_W("Node offline, but voltage is OK (%.2fV)", voltage);
} else {
EIF_LOG_I("System healthy");
}
}
#define EIF_TAG_WITH_UNUSED Helper to define a local logging 'TAG' identifier. Definition: esp_iot_framework_core_macros.h:88 #define EIF_LOG_W(...) Logs a warning message using the ESP_LOGW severity. Definition: esp_iot_framework_core_macros.h:227 #define EIF_LOG_I(...) Logs an informational message using the ESP_LOGI severity. Definition: esp_iot_framework_core_macros.h:233 #define EIF_LOG_E(...) Logs an error message using the ESP_LOGE severity. Definition: esp_iot_framework_core_macros.h:221 | ||||
| #define | EIF_LOG_E(...) EIF_PRINT(ESP_LOGE, __VA_ARGS__) | |||
| Logs an error message using the ESP_LOGE severity. | ||||
| #define | EIF_LOG_W(...) EIF_PRINT(ESP_LOGW, __VA_ARGS__) | |||
| Logs a warning message using the ESP_LOGW severity. | ||||
| #define | EIF_LOG_I(...) EIF_PRINT(ESP_LOGI, __VA_ARGS__) | |||
| Logs an informational message using the ESP_LOGI severity. | ||||
| #define | EIF_LOG_D(...) EIF_PRINT(ESP_LOGD, __VA_ARGS__) | |||
| Logs a debug message using the ESP_LOGD severity. | ||||
This group contains macros for printing formatted messages to the console output. The output style and threshold level are configured via Kconfig.
| #define EIF_TAG_WITH_UNUSED static const char* const TAG __attribute__((unused)) = |
This macro declares a string named TAG. It automatically adds an unused attribute ([[maybe_unused]] for C++, __attribute__((unused)) for C or nothing if the compiler does not support it) to suppress compiler warnings and satisfy MISRA C requirements when all logging macros in the scope are stripped out by the preprocessor.
#undef.Example of use:
| #define EIF_PRINT | ( | m_macro, | |
| m_format, | |||
| ... | |||
| ) | m_macro(TAG, "%s:%d (%s) " m_format, __FILE__, __LINE__, __func__, ##__VA_ARGS__) |
This macro forwards messages directly to the ESP logging system. It implicitly uses the local TAG variable, which must be defined in the current scope.
TAG identifier being defined and accessible within the current scope. Behavior depends on the CONFIG_EIF_LOG_SHOW_METADATA configuration:| [in] | m_macro | Target ESP-IDF logging macro (e.g., ESP_LOGI, ESP_LOGW, ESP_LOGE). |
| [in] | m_format | Format string compatible with printf. |
| [in] | ... | Optional variadic arguments for the format string. |
Example of use:
| #define EIF_SHOW_ESP_ERR_T | ( | m_result, | |
| m_expr, | |||
| m_format, | |||
| ... | |||
| ) |
This macro executes the expression m_expr regardless of any previous status. If the resulting execution status is not ESP_OK, it fetches the error name via esp_err_to_name() and outputs a warning-level log containing the failure context. The execution status is always written to m_result. It is ideal for cleanup blocks or logging forced actions, such as closing sockets before restarting.
m_result. Do not use it inside sequential checking chains (EIF_IF_OK_*) as it can mask earlier initialization failures.| [out] | m_result | Status variable (esp_err_t) to store the execution result. The previous value is overwritten unconditionally. |
| [in] | m_expr | The function call or expression returning esp_err_t. |
| [in] | m_format | Printf-compliant format string for warning details. |
| [in] | ... | Optional variadic arguments matching the format string. |
Example of use: