From bc508769d4be28c204ec2b4c90e13056fc3602fd Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Tue, 24 Jun 2025 17:37:03 +0200 Subject: [PATCH] Add filename and line number back to esp log --- .../espcoredump/include_core_dump/esp_core_dump_types.h | 2 +- components/log/include/esp_log_format.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/espcoredump/include_core_dump/esp_core_dump_types.h b/components/espcoredump/include_core_dump/esp_core_dump_types.h index 79a92d59e4..f9aca3ba44 100644 --- a/components/espcoredump/include_core_dump/esp_core_dump_types.h +++ b/components/espcoredump/include_core_dump/esp_core_dump_types.h @@ -19,7 +19,7 @@ extern "C" { #include "core_dump_checksum.h" #if CONFIG_ESP_COREDUMP_LOGS -#define ESP_COREDUMP_LOG( level, format, ... ) if (LOG_LOCAL_LEVEL >= level) { esp_rom_printf((format), esp_log_early_timestamp(), (const char *)TAG, ##__VA_ARGS__); } +#define ESP_COREDUMP_LOG( level, format, ... ) if (LOG_LOCAL_LEVEL >= level) { esp_rom_printf(format, esp_log_early_timestamp(), (const char *)TAG, ##__VA_ARGS__); } #else #define ESP_COREDUMP_LOG( level, format, ... ) // dummy define doing nothing #endif diff --git a/components/log/include/esp_log_format.h b/components/log/include/esp_log_format.h index 82e18139bb..ebb7210515 100644 --- a/components/log/include/esp_log_format.h +++ b/components/log/include/esp_log_format.h @@ -11,8 +11,12 @@ extern "C" { #endif /** @cond */ + +#define ESP_LOG_STRINGIFY2(x) #x +#define ESP_LOG_STRINGIFY(x) ESP_LOG_STRINGIFY2(x) + // 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 LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " %s:" ESP_LOG_STRINGIFY(__LINE__) " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n", (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) #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 */