From 9f2b892512ee1bc9e1142cc125a793ce6ef5da00 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Fri, 17 May 2024 22:52:19 +0300 Subject: [PATCH] feat(log): Move LOG_FORMAT macros out of esp_log.h --- components/log/include/esp_log.h | 9 +-------- components/log/include/esp_log_format.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 components/log/include/esp_log_format.h diff --git a/components/log/include/esp_log.h b/components/log/include/esp_log.h index 78bd661f97..8a00d23787 100644 --- a/components/log/include/esp_log.h +++ b/components/log/include/esp_log.h @@ -16,18 +16,12 @@ #include "esp_log_buffer.h" #include "esp_log_timestamp.h" #include "esp_log_write.h" +#include "esp_log_format.h" #ifdef __cplusplus extern "C" { #endif -/** @cond */ - -#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" -#define LOG_SYSTEM_TIME_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%s) %s: " format LOG_RESET_COLOR "\n" - -/** @endcond */ - /// macro to output logs in startup code, before heap allocator and syscalls have been initialized. /// Log at ``ESP_LOG_ERROR`` level. @see ``printf``,``ESP_LOGE``,``ESP_DRAM_LOGE`` @@ -208,7 +202,6 @@ extern "C" { #endif // !(defined(__cplusplus) && (__cplusplus > 201703L)) /** @cond */ -#define _ESP_LOG_DRAM_LOG_FORMAT(letter, format) DRAM_STR(#letter " %s: " format "\n") #if defined(__cplusplus) && (__cplusplus > 201703L) #define ESP_DRAM_LOG_IMPL(tag, format, log_level, log_tag_letter, ...) do { \ diff --git a/components/log/include/esp_log_format.h b/components/log/include/esp_log_format.h new file mode 100644 index 0000000000..82e18139bb --- /dev/null +++ b/components/log/include/esp_log_format.h @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** @cond */ +// For backward compatibility (these macros are not used in the log v2). +#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" +#define _ESP_LOG_DRAM_LOG_FORMAT(letter, format) DRAM_STR(#letter " %s: " format "\n") +#define LOG_SYSTEM_TIME_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%s) %s: " format LOG_RESET_COLOR "\n" +/** @endcond */ + +#ifdef __cplusplus +} +#endif