mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
esp_log: Implemented esp_log_level_get(TAG)
Closes https://github.com/espressif/esp-idf/pull/6573
This commit is contained in:
@@ -71,6 +71,16 @@ extern esp_log_level_t esp_log_default_level;
|
|||||||
*/
|
*/
|
||||||
void esp_log_level_set(const char* tag, esp_log_level_t level);
|
void esp_log_level_set(const char* tag, esp_log_level_t level);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get log level for given tag, can be used to avoid expensive log statements
|
||||||
|
*
|
||||||
|
* @param tag Tag of the log to query current level. Must be a non-NULL zero terminated
|
||||||
|
* string.
|
||||||
|
*
|
||||||
|
* @return The current log level for the given tag
|
||||||
|
*/
|
||||||
|
esp_log_level_t esp_log_level_get(const char* tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set function used to output log entries
|
* @brief Set function used to output log entries
|
||||||
*
|
*
|
||||||
|
@@ -141,6 +141,25 @@ void esp_log_level_set(const char *tag, esp_log_level_t level)
|
|||||||
esp_log_impl_unlock();
|
esp_log_impl_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_log_level_t esp_log_level_get(const char* tag)
|
||||||
|
{
|
||||||
|
esp_log_impl_lock();
|
||||||
|
esp_log_level_t level_for_tag;
|
||||||
|
// 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_uncached_log_level(tag, &level_for_tag)) {
|
||||||
|
level_for_tag = esp_log_default_level;
|
||||||
|
}
|
||||||
|
add_to_cache(tag, level_for_tag);
|
||||||
|
#ifdef LOG_BUILTIN_CHECKS
|
||||||
|
++s_log_cache_misses;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
esp_log_impl_unlock();
|
||||||
|
|
||||||
|
return level_for_tag;
|
||||||
|
}
|
||||||
|
|
||||||
void clear_log_level_list(void)
|
void clear_log_level_list(void)
|
||||||
{
|
{
|
||||||
uncached_tag_entry_t *it;
|
uncached_tag_entry_t *it;
|
||||||
|
Reference in New Issue
Block a user