trace.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Squeezelite for esp32
  3. *
  4. * (c) Sebastien 2019
  5. * Philippe G. 2019, philippe_44@outlook.com
  6. *
  7. * This software is released under the MIT License.
  8. * https://opensource.org/licenses/MIT
  9. *
  10. */
  11. #pragma once
  12. #ifndef QUOTE
  13. #define QUOTE(name) #name
  14. #endif
  15. #ifndef STR
  16. #define STR(macro) QUOTE(macro)
  17. #endif
  18. #define ESP_LOG_DEBUG_EVENT(tag,e) ESP_LOGD(tag,"evt: " e)
  19. #ifndef STR_OR_ALT
  20. #define STR_OR_ALT(str,alt) (str?str:alt)
  21. #endif
  22. #ifndef STR_OR_BLANK
  23. #define STR_OR_BLANK(p) p == NULL ? "" : p
  24. #endif
  25. #define ENUM_TO_STRING(g) \
  26. case g: \
  27. return STR(g); \
  28. break;
  29. extern const char unknown_string_placeholder[];
  30. extern const char * str_or_unknown(const char * str);
  31. extern const char * str_or_null(const char * str);
  32. void memtrace_print_delta(const char * msg, const char * TAG, const char * function);
  33. #ifdef ENABLE_MEMTRACE
  34. #define MEMTRACE_PRINT_DELTA() memtrace_print_delta(NULL,TAG,__FUNCTION__);
  35. #define MEMTRACE_PRINT_DELTA_MESSAGE(x) memtrace_print_delta(x,TAG,__FUNCTION__);
  36. #else
  37. #define MEMTRACE_PRINT_DELTA()
  38. #define MEMTRACE_PRINT_DELTA_MESSAGE(x) ESP_LOGD(TAG,"%s",x);
  39. #endif
  40. #ifndef FREE_AND_NULL
  41. #define FREE_AND_NULL(x) if(x) { free(x); x=NULL; }
  42. #endif
  43. #ifndef CASE_TO_STR
  44. #define CASE_TO_STR(x) case x: return STR(x); break;
  45. #endif