feat(log): Use ESP_LOG_LEVEL_LEN in cache tag_log_level

This commit is contained in:
Konstantin Kondrashov
2024-06-17 17:18:16 +03:00
committed by BOT
parent 21f7309a52
commit fa3b26bbc3
2 changed files with 8 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
#pragma once
#include <stdint.h>
#include "esp_assert.h"
#include "sdkconfig.h"
#ifdef __cplusplus
@@ -26,7 +27,11 @@ typedef enum {
ESP_LOG_MAX = 6, /*!< Number of levels supported */
} esp_log_level_t;
#define ESP_LOG_LEVEL_LEN (3) /*!< Number of bits used to represent the log level */
#define ESP_LOG_LEVEL_MASK ((1 << ESP_LOG_LEVEL_LEN) - 1) /*!< Mask for log level */
/** @cond */
ESP_STATIC_ASSERT(ESP_LOG_MAX <= ESP_LOG_LEVEL_MASK, "Log level items of esp_log_level_t must fit ESP_LOG_LEVEL_MASK");
// LOG_LOCAL_LEVEL controls what log levels are included in the binary.
#ifndef LOG_LOCAL_LEVEL

View File

@@ -56,12 +56,12 @@
ESP_STATIC_ASSERT(((CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE & (CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE + 1)) == 0), "Number of tags to be cached must be 2**n - 1, n >= 2. [1, 3, 7, 15, 31, 63, 127, 255, ...]");
#define TAG_CACHE_SIZE (CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE)
#define MAX_GENERATION ((1 << 29) - 1)
#define MAX_GENERATION ((1 << (32 - ESP_LOG_LEVEL_LEN)) - 1)
typedef struct {
const char *tag;
uint32_t level : 3;
uint32_t generation : 29; // this size should be the same in MAX_GENERATION
uint32_t level : ESP_LOG_LEVEL_LEN;
uint32_t generation : (32 - ESP_LOG_LEVEL_LEN); // this size should be the same in MAX_GENERATION
} cached_tag_entry_t;
static cached_tag_entry_t s_log_cache[TAG_CACHE_SIZE];