Browse Source

better use of strings in log messages

ugv_io
Alex Mikhalev 6 years ago
parent
commit
d3eccdbcb1
  1. 8
      components/sx127x_driver/sx127x_internal.h

8
components/sx127x_driver/sx127x_internal.h

@ -73,7 +73,7 @@ typedef enum sx127x_op_mode {
#ifdef NODEBUG #ifdef NODEBUG
#define SX127X_CHECK(check, str, ret_val, ...) \ #define SX127X_CHECK(check, str, ret_val, ...) \
if (!(check)) { \ if (!(check)) { \
ESP_LOGE(SX127X_TAG, str, ##__VA_ARGS__); \ ESP_LOGE(SX127X_TAG, str, ##__VA_ARGS__); \
return (ret_val); \ return (ret_val); \
} }
#define SX127X_ERROR_CHECK(ret) \ #define SX127X_ERROR_CHECK(ret) \
@ -87,7 +87,7 @@ typedef enum sx127x_op_mode {
#else #else
#define SX127X_CHECK(check, str, ret_val, ...) \ #define SX127X_CHECK(check, str, ret_val, ...) \
if (!(check)) { \ if (!(check)) { \
ESP_LOGE(SX127X_TAG, "%s:%d: " #check ": " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ ESP_LOGE(SX127X_TAG, "%s:%d: check %s failed: " str, __FUNCTION__, __LINE__, #check, ##__VA_ARGS__); \
return (ret_val); \ return (ret_val); \
} }
#define SX127X_ERROR_CHECK(ret) \ #define SX127X_ERROR_CHECK(ret) \
@ -95,7 +95,7 @@ typedef enum sx127x_op_mode {
esp_err_t _error_code = (ret); \ esp_err_t _error_code = (ret); \
if (_error_code != ESP_OK) { \ if (_error_code != ESP_OK) { \
const char *_error_name = esp_err_to_name(_error_code); \ const char *_error_name = esp_err_to_name(_error_code); \
ESP_LOGE(SX127X_TAG, "%s:%d: %s (%d)", __FUNCTION__, __LINE__, _error_name, _error_code); \ ESP_LOGE(SX127X_TAG, "%s:%d: %s (%d)", __FUNCTION__, __LINE__, _error_name, _error_code); \
return _error_code; \ return _error_code; \
} \ } \
} }
@ -104,7 +104,7 @@ typedef enum sx127x_op_mode {
esp_err_t _error_code = (ret); \ esp_err_t _error_code = (ret); \
if (_error_code != ESP_OK) { \ if (_error_code != ESP_OK) { \
const char *_error_name = esp_err_to_name(_error_code); \ const char *_error_name = esp_err_to_name(_error_code); \
ESP_LOGE(SX127X_TAG, "%s:%d: " #fun ": %s (%d)", __FUNCTION__, __LINE__, _error_name, _error_code); \ ESP_LOGE(SX127X_TAG, "%s:%d: %s failed: %s (%d)", __FUNCTION__, __LINE__, #fun, _error_name, _error_code); \
return _error_code; \ return _error_code; \
} \ } \
} }

Loading…
Cancel
Save