From 0dff9ed79db6f2fe234566b4b32afc4a987b41e7 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 7 Dec 2016 12:01:30 +0800 Subject: [PATCH] drivers: remove file paths from log statements Function name and error string are usually sufficient to find the place which has triggered an error. __FILE__ macro generates a string which has absolute file name (with our build system), so there is a lot of long strings present in the program because of that. Fixes https://github.com/espressif/esp-idf/issues/126 --- components/driver/gpio.c | 11 ++++++----- components/driver/ledc.c | 11 ++++++----- components/driver/pcnt.c | 12 +++++++----- components/driver/rmt.c | 12 +++++++----- components/driver/timer.c | 12 +++++++----- components/driver/uart.c | 12 +++++++----- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/components/driver/gpio.c b/components/driver/gpio.c index d5d4d9d40..b2737bc7b 100644 --- a/components/driver/gpio.c +++ b/components/driver/gpio.c @@ -20,11 +20,12 @@ #include "soc/soc.h" #include "esp_log.h" -static const char* GPIO_TAG = "GPIO"; -#define GPIO_CHECK(a, str, ret_val) if (!(a)) { \ - ESP_LOGE(GPIO_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret_val); \ - } +static const char* GPIO_TAG = "gpio"; +#define GPIO_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(GPIO_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } const uint32_t GPIO_PIN_MUX_REG[GPIO_PIN_COUNT] = { GPIO_PIN_REG_0, diff --git a/components/driver/ledc.c b/components/driver/ledc.c index 893c78a6b..1a0e527d5 100644 --- a/components/driver/ledc.c +++ b/components/driver/ledc.c @@ -20,12 +20,13 @@ #include "driver/ledc.h" #include "esp_log.h" -static const char* LEDC_TAG = "LEDC"; +static const char* LEDC_TAG = "ledc"; static portMUX_TYPE ledc_spinlock = portMUX_INITIALIZER_UNLOCKED; -#define LEDC_CHECK(a, str, ret_val) if (!(a)) { \ - ESP_LOGE(LEDC_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret_val); \ - } +#define LEDC_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(LEDC_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t div_num, uint32_t bit_num, ledc_clk_src_t clk_src) { diff --git a/components/driver/pcnt.c b/components/driver/pcnt.c index b39d53a80..67f0044f5 100644 --- a/components/driver/pcnt.c +++ b/components/driver/pcnt.c @@ -23,12 +23,14 @@ #define PCNT_COUNT_MODE_ERR_STR "PCNT COUNTER MODE ERROR" #define PCNT_CTRL_MODE_ERR_STR "PCNT CTRL MODE ERROR" #define PCNT_EVT_TYPE_ERR_STR "PCNT value type error" -#define PCNT_CHECK(a,str,ret_val) if(!(a)) { \ - ESP_LOGE(PCNT_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret_val); \ - } -static const char* PCNT_TAG = "PCNT"; +static const char* PCNT_TAG = "pcnt"; +#define PCNT_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(PCNT_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } + static portMUX_TYPE pcnt_spinlock = portMUX_INITIALIZER_UNLOCKED; #define PCNT_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 9fc36d49c..16e9693af 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -43,13 +43,15 @@ #define RMT_DRIVER_ERROR_STR "RMT DRIVER ERR" #define RMT_DRIVER_LENGTH_ERROR_STR "RMT PARAM LEN ERROR" -static const char* RMT_TAG = "RMT"; +static const char* RMT_TAG = "rmt"; static bool s_rmt_driver_installed = false; -#define RMT_CHECK(a, str, ret) if (!(a)) { \ - ESP_LOGE(RMT_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret); \ - } +#define RMT_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(RMT_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } + static portMUX_TYPE rmt_spinlock = portMUX_INITIALIZER_UNLOCKED; typedef struct { diff --git a/components/driver/timer.c b/components/driver/timer.c index b305a4146..8aab20072 100644 --- a/components/driver/timer.c +++ b/components/driver/timer.c @@ -20,11 +20,13 @@ #include "driver/timer.h" #include "driver/periph_ctrl.h" -static const char* TIMER_TAG = "TIMER_GROUP"; -#define TIMER_CHECK(a, str, ret_val) if (!(a)) { \ - ESP_LOGE(TIMER_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret_val); \ - } +static const char* TIMER_TAG = "timer_group"; +#define TIMER_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(TIMER_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } + #define TIMER_GROUP_NUM_ERROR "TIMER GROUP NUM ERROR" #define TIMER_NUM_ERROR "HW TIMER NUM ERROR" #define TIMER_PARAM_ADDR_ERROR "HW TIMER PARAM ADDR ERROR" diff --git a/components/driver/uart.c b/components/driver/uart.c index 59b4904dc..6b894de96 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -27,11 +27,13 @@ #include "driver/uart.h" #include "driver/gpio.h" -static const char* UART_TAG = "UART"; -#define UART_CHECK(a, str, ret) if (!(a)) { \ - ESP_LOGE(UART_TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \ - return (ret); \ - } +static const char* UART_TAG = "uart"; +#define UART_CHECK(a, str, ret_val) \ + if (!(a)) { \ + ESP_LOGE(UART_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret_val); \ + } + #define UART_EMPTY_THRESH_DEFAULT (10) #define UART_FULL_THRESH_DEFAULT (120) #define UART_TOUT_THRESH_DEFAULT (10)