mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(ble_audio): Support log compression for ISO & LE Audio logs
This commit is contained in:
@@ -51,13 +51,24 @@ static inline void k_mutex_delete(struct k_mutex *mutex)
|
||||
mutex->handle = NULL;
|
||||
}
|
||||
|
||||
/* Inline log helper with a fixed tag. These functions are inlined into many
|
||||
* translation units (including api/ wrappers), and not all of them call
|
||||
* LOG_MODULE_REGISTER, so we cannot reference the per-TU __iso_log_tag
|
||||
* here. Use a hardcoded "ISO_MUTEX" tag instead, keeping the same level
|
||||
* gating. */
|
||||
#if CONFIG_BT_ISO_NO_LOG || (CONFIG_BT_ISO_LOG_LEVEL < BT_ISO_LOG_ERROR)
|
||||
#define K_MUTEX_LOG_ERR(fmt, args...)
|
||||
#else
|
||||
#define K_MUTEX_LOG_ERR(fmt, args...) BT_ISO_LOGE("ISO_MUTEX", fmt, ## args)
|
||||
#endif
|
||||
|
||||
static inline int k_mutex_lock(struct k_mutex *mutex, uint32_t timeout)
|
||||
{
|
||||
assert(mutex);
|
||||
assert(mutex->handle);
|
||||
|
||||
if (xSemaphoreTakeRecursive(mutex->handle, timeout) != pdTRUE) {
|
||||
LOG_ERR("KMutexLockFail");
|
||||
K_MUTEX_LOG_ERR("LockFail");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -70,7 +81,7 @@ static inline int k_mutex_unlock(struct k_mutex *mutex)
|
||||
assert(mutex->handle);
|
||||
|
||||
if (xSemaphoreGiveRecursive(mutex->handle) != pdTRUE) {
|
||||
LOG_ERR("KMutexUnlockFail");
|
||||
K_MUTEX_LOG_ERR("UnlockFail");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018 Nordic Semiconductor ASA
|
||||
* SPDX-FileContributor: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -14,15 +15,28 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
/* esp_ble_iso, esp_ble_audio and any future ISO consumer are compiled
|
||||
* under the unified BLE_ISO compression channel and share one
|
||||
* iso_log_index.h with one monotonic log-id counter — no per-consumer
|
||||
* index header, no per-TU sentinel needed. */
|
||||
#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE
|
||||
#include "iso_log_index.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int ets_printf(const char *fmt, ...);
|
||||
/* Define a per-translation-unit log tag.
|
||||
* The first argument is the module name (an identifier); it is stringified to
|
||||
* produce the tag passed to esp_log_write(). LOG_MODULE_DECLARE has the same
|
||||
* effect and is provided for Zephyr API parity (in our port the two expand to
|
||||
* identical code). */
|
||||
#define LOG_MODULE_REGISTER(name, ...) \
|
||||
static const char *const __iso_log_tag __attribute__((unused)) = #name
|
||||
|
||||
#define LOG_MODULE_REGISTER(...)
|
||||
|
||||
#define LOG_MODULE_DECLARE(...)
|
||||
#define LOG_MODULE_DECLARE(name, ...) \
|
||||
static const char *const __iso_log_tag __attribute__((unused)) = #name
|
||||
|
||||
#define BT_ISO_LOG_COLOR_BLACK "30"
|
||||
#define BT_ISO_LOG_COLOR_RED "31"
|
||||
@@ -47,14 +61,6 @@ extern int ets_printf(const char *fmt, ...);
|
||||
#define BT_ISO_LOG_DEBUG 4
|
||||
#define BT_ISO_LOG_VERBOSE 5
|
||||
|
||||
#define BT_AUDIO_LOG_ERROR BT_ISO_LOG_ERROR
|
||||
#define BT_AUDIO_LOG_WARN BT_ISO_LOG_WARN
|
||||
#define BT_AUDIO_LOG_INFO BT_ISO_LOG_INFO
|
||||
#define BT_AUDIO_LOG_DEBUG BT_ISO_LOG_DEBUG
|
||||
#define BT_AUDIO_LOG_VERBOSE BT_ISO_LOG_VERBOSE
|
||||
|
||||
#define BT_ISO_LOG_TAG "ISO"
|
||||
|
||||
#define BT_ISO_LOGE(tag, format, ...) \
|
||||
esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), \
|
||||
esp_log_timestamp(), tag, ##__VA_ARGS__);
|
||||
@@ -78,25 +84,25 @@ extern int ets_printf(const char *fmt, ...);
|
||||
#define LOG_DBG(fmt, args...)
|
||||
#else /* CONFIG_BT_ISO_NO_LOG */
|
||||
#if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR)
|
||||
#define LOG_ERR(fmt, args...) BT_ISO_LOGE(BT_ISO_LOG_TAG, fmt, ## args)
|
||||
#define LOG_ERR(fmt, args...) BT_ISO_LOGE(__iso_log_tag, fmt, ## args)
|
||||
#else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR) */
|
||||
#define LOG_ERR(fmt, args...)
|
||||
#endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR) */
|
||||
|
||||
#if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN)
|
||||
#define LOG_WRN(fmt, args...) BT_ISO_LOGW(BT_ISO_LOG_TAG, fmt, ## args)
|
||||
#define LOG_WRN(fmt, args...) BT_ISO_LOGW(__iso_log_tag, fmt, ## args)
|
||||
#else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN) */
|
||||
#define LOG_WRN(fmt, args...)
|
||||
#endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN) */
|
||||
|
||||
#if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO)
|
||||
#define LOG_INF(fmt, args...) BT_ISO_LOGI(BT_ISO_LOG_TAG, fmt, ## args)
|
||||
#define LOG_INF(fmt, args...) BT_ISO_LOGI(__iso_log_tag, fmt, ## args)
|
||||
#else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO) */
|
||||
#define LOG_INF(fmt, args...)
|
||||
#endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO) */
|
||||
|
||||
#if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG)
|
||||
#define LOG_DBG(fmt, args...) BT_ISO_LOGD(BT_ISO_LOG_TAG, fmt, ## args)
|
||||
#define LOG_DBG(fmt, args...) BT_ISO_LOGD(__iso_log_tag, fmt, ## args)
|
||||
#else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) */
|
||||
#define LOG_DBG(fmt, args...)
|
||||
#endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) */
|
||||
|
||||
Reference in New Issue
Block a user