mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
log: Cause ESP_EARLY_LOGx in the app to use the default runtime log level
Tag filtering still doesn't work for this log type, but it will use the default '*' log level instead of only the runtime level. * Closes https://github.com/espressif/esp-idf/issues/2285 * Related to https://github.com/espressif/esp-idf/issues/5542
This commit is contained in:
parent
6bd9580137
commit
29348270e7
@ -40,6 +40,15 @@ typedef enum {
|
|||||||
|
|
||||||
typedef int (*vprintf_like_t)(const char *, va_list);
|
typedef int (*vprintf_like_t)(const char *, va_list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default log level
|
||||||
|
*
|
||||||
|
* This is used by the definition of ESP_EARLY_LOGx macros. It is not
|
||||||
|
* recommended to set this directly, call esp_log_level_set("*", level)
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
extern esp_log_level_t esp_log_default_level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set log level for given tag
|
* @brief Set log level for given tag
|
||||||
*
|
*
|
||||||
@ -282,8 +291,16 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
|||||||
/// macro to output logs in startup code at ``ESP_LOG_VERBOSE`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf``
|
/// macro to output logs in startup code at ``ESP_LOG_VERBOSE`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf``
|
||||||
#define ESP_EARLY_LOGV( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_VERBOSE, V, ##__VA_ARGS__)
|
#define ESP_EARLY_LOGV( tag, format, ... ) ESP_LOG_EARLY_IMPL(tag, format, ESP_LOG_VERBOSE, V, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef BOOTLOADER_BUILD
|
||||||
|
#define _ESP_LOG_EARLY_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level))
|
||||||
|
#else
|
||||||
|
/* For early log, there is no log tag filtering. So we want to log only if both the LOG_LOCAL_LEVEL and the
|
||||||
|
currently configured min log level are higher than the log level */
|
||||||
|
#define _ESP_LOG_EARLY_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level) && esp_log_default_level >= (log_level))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ESP_LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
#define ESP_LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
||||||
if (LOG_LOCAL_LEVEL >= log_level) { \
|
if (_ESP_LOG_EARLY_ENABLED(log_level)) { \
|
||||||
esp_rom_printf(LOG_FORMAT(log_tag_letter, format), esp_log_timestamp(), tag, ##__VA_ARGS__); \
|
esp_rom_printf(LOG_FORMAT(log_tag_letter, format), esp_log_timestamp(), tag, ##__VA_ARGS__); \
|
||||||
}} while(0)
|
}} while(0)
|
||||||
|
|
||||||
@ -351,7 +368,8 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
|||||||
/**
|
/**
|
||||||
* @brief Macro to output logs when the cache is disabled. log at ``ESP_LOG_ERROR`` level.
|
* @brief Macro to output logs when the cache is disabled. log at ``ESP_LOG_ERROR`` level.
|
||||||
*
|
*
|
||||||
* Similar to `ESP_EARLY_LOGE`, the log level cannot be changed by `esp_log_level_set`.
|
* Similar to `ESP_EARLY_LOGE`, the log level cannot be changed per-tag, however
|
||||||
|
* esp_log_level_set("*", level) will set the default level which controls these log lines also.
|
||||||
*
|
*
|
||||||
* Usage: `ESP_DRAM_LOGE(DRAM_STR("my_tag"), "format", or `ESP_DRAM_LOGE(TAG, "format", ...)`,
|
* Usage: `ESP_DRAM_LOGE(DRAM_STR("my_tag"), "format", or `ESP_DRAM_LOGE(TAG, "format", ...)`,
|
||||||
* where TAG is a char* that points to a str in the DRAM.
|
* where TAG is a char* that points to a str in the DRAM.
|
||||||
@ -374,7 +392,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format,
|
|||||||
#define _ESP_LOG_DRAM_LOG_FORMAT(letter, format) DRAM_STR(#letter " %s: " format "\n")
|
#define _ESP_LOG_DRAM_LOG_FORMAT(letter, format) DRAM_STR(#letter " %s: " format "\n")
|
||||||
|
|
||||||
#define ESP_DRAM_LOG_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
#define ESP_DRAM_LOG_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
||||||
if (LOG_LOCAL_LEVEL >= log_level) { \
|
if (_ESP_LOG_EARLY_ENABLED(log_level)) { \
|
||||||
esp_rom_printf(_ESP_LOG_DRAM_LOG_FORMAT(log_tag_letter, format), tag, ##__VA_ARGS__); \
|
esp_rom_printf(_ESP_LOG_DRAM_LOG_FORMAT(log_tag_letter, format), tag, ##__VA_ARGS__); \
|
||||||
}} while(0)
|
}} while(0)
|
||||||
/** @endcond */
|
/** @endcond */
|
||||||
|
@ -61,7 +61,7 @@ typedef struct uncached_tag_entry_ {
|
|||||||
char tag[0]; // beginning of a zero-terminated string
|
char tag[0]; // beginning of a zero-terminated string
|
||||||
} uncached_tag_entry_t;
|
} uncached_tag_entry_t;
|
||||||
|
|
||||||
static esp_log_level_t s_log_default_level = ESP_LOG_VERBOSE;
|
esp_log_level_t esp_log_default_level = CONFIG_LOG_DEFAULT_LEVEL;
|
||||||
static SLIST_HEAD(log_tags_head, uncached_tag_entry_) s_log_tags = SLIST_HEAD_INITIALIZER(s_log_tags);
|
static SLIST_HEAD(log_tags_head, uncached_tag_entry_) s_log_tags = SLIST_HEAD_INITIALIZER(s_log_tags);
|
||||||
static cached_tag_entry_t s_log_cache[TAG_CACHE_SIZE];
|
static cached_tag_entry_t s_log_cache[TAG_CACHE_SIZE];
|
||||||
static uint32_t s_log_cache_max_generation = 0;
|
static uint32_t s_log_cache_max_generation = 0;
|
||||||
@ -96,7 +96,7 @@ void esp_log_level_set(const char *tag, esp_log_level_t level)
|
|||||||
|
|
||||||
// for wildcard tag, remove all linked list items and clear the cache
|
// for wildcard tag, remove all linked list items and clear the cache
|
||||||
if (strcmp(tag, "*") == 0) {
|
if (strcmp(tag, "*") == 0) {
|
||||||
s_log_default_level = level;
|
esp_log_default_level = level;
|
||||||
clear_log_level_list();
|
clear_log_level_list();
|
||||||
esp_log_impl_unlock();
|
esp_log_impl_unlock();
|
||||||
return;
|
return;
|
||||||
@ -166,7 +166,7 @@ void esp_log_writev(esp_log_level_t level,
|
|||||||
// Look for the tag in cache first, then in the linked list of all tags
|
// Look for the tag in cache first, then in the linked list of all tags
|
||||||
if (!get_cached_log_level(tag, &level_for_tag)) {
|
if (!get_cached_log_level(tag, &level_for_tag)) {
|
||||||
if (!get_uncached_log_level(tag, &level_for_tag)) {
|
if (!get_uncached_log_level(tag, &level_for_tag)) {
|
||||||
level_for_tag = s_log_default_level;
|
level_for_tag = esp_log_default_level;
|
||||||
}
|
}
|
||||||
add_to_cache(tag, level_for_tag);
|
add_to_cache(tag, level_for_tag);
|
||||||
#ifdef LOG_BUILTIN_CHECKS
|
#ifdef LOG_BUILTIN_CHECKS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user