fix(esp-hal-log):Provide a default TAG name for USE_ESP_IDF_LOG logging macro (#9686)
* change(logging): Provide a default TAG name for USE_ESP_IDF_LOG The ESP-IDF logging library has some nice features such as log forwarding. esp32-hal-log.h has long supported the USE_ESP_IDF_LOG macro, but due to subsequent changes, it requires a global TAG preprocessor macro to be defined. The macro name is too generic and just having a sane default would be preferable. * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
8091b7a77c
commit
d94b32ed20
1 changed files with 61 additions and 60 deletions
|
|
@ -80,6 +80,12 @@ extern "C" {
|
||||||
#define ARDUHAL_LOG_COLOR_PRINT_END
|
#define ARDUHAL_LOG_COLOR_PRINT_END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ESP_IDF_LOG
|
||||||
|
#ifndef ARDUHAL_ESP_LOG_TAG
|
||||||
|
#define ARDUHAL_ESP_LOG_TAG "ARDUINO"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *pathToFileName(const char *path);
|
const char *pathToFileName(const char *path);
|
||||||
int log_printf(const char *fmt, ...);
|
int log_printf(const char *fmt, ...);
|
||||||
void log_print_buf(const uint8_t *b, size_t len);
|
void log_print_buf(const uint8_t *b, size_t len);
|
||||||
|
|
@ -104,15 +110,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_v(format, ...) \
|
#define log_v(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_VERBOSE, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_v(format, ...) \
|
#define isr_log_v(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_v(b, l) \
|
#define log_buf_v(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_VERBOSE); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_VERBOSE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -140,15 +146,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_d(format, ...) \
|
#define log_d(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_d(format, ...) \
|
#define isr_log_d(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_d(b, l) \
|
#define log_buf_d(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_DEBUG); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_DEBUG); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -176,15 +182,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_i(format, ...) \
|
#define log_i(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_i(format, ...) \
|
#define isr_log_i(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_i(b, l) \
|
#define log_buf_i(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_INFO); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_INFO); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -212,15 +218,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_w(format, ...) \
|
#define log_w(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_w(format, ...) \
|
#define isr_log_w(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_w(b, l) \
|
#define log_buf_w(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_WARN); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_WARN); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -248,15 +254,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_e(format, ...) \
|
#define log_e(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_e(format, ...) \
|
#define isr_log_e(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_e(b, l) \
|
#define log_buf_e(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_ERROR); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -284,15 +290,15 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
#else
|
#else
|
||||||
#define log_n(format, ...) \
|
#define log_n(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__); \
|
ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, ARDUHAL_ESP_LOG_TAG, format, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define isr_log_n(format, ...) \
|
#define isr_log_n(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__); \
|
ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), ARDUHAL_ESP_LOG_TAG, ##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define log_buf_n(b, l) \
|
#define log_buf_n(b, l) \
|
||||||
do { \
|
do { \
|
||||||
ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR); \
|
ESP_LOG_BUFFER_HEXDUMP(ARDUHAL_ESP_LOG_TAG, b, l, ESP_LOG_ERROR); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
@ -309,12 +315,7 @@ void log_print_buf(const uint8_t *b, size_t len);
|
||||||
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
#ifdef USE_ESP_IDF_LOG
|
#ifndef USE_ESP_IDF_LOG
|
||||||
//#ifndef TAG
|
|
||||||
//#define TAG "ARDUINO"
|
|
||||||
//#endif
|
|
||||||
//#define log_n(format, ...) myLog(ESP_LOG_NONE, format, ##__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#ifdef CONFIG_ARDUHAL_ESP_LOG
|
#ifdef CONFIG_ARDUHAL_ESP_LOG
|
||||||
#undef ESP_LOGE
|
#undef ESP_LOGE
|
||||||
#undef ESP_LOGW
|
#undef ESP_LOGW
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue