assimp_tinyusdz_logging.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Usage
  3. * Add line below all other #include statements:
  4. * #include "../../../assimp_tinyusdz_logging.inc"
  5. * to files:
  6. * - contrib/tinyusdz/tinyusdz_repo/src/tydra/render-data.cc
  7. * - contrib/tinyusdz/tinyusdz_repo/src/tydra/scene-access.cc
  8. */
  9. #pragma once
  10. #if defined(__ANDROID__)
  11. #include <sstream>
  12. #include <android/log.h>
  13. #define TINYUSDZLOGT(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__))
  14. #define TINYUSDZLOG0(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEFAULT, tag, __VA_ARGS__))
  15. #define TINYUSDZLOGD(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__))
  16. #define TINYUSDZLOGI(tag, ...) ((void)__android_log_print(ANDROID_LOG_INFO, tag, __VA_ARGS__))
  17. #define TINYUSDZLOGW(tag, ...) ((void)__android_log_print(ANDROID_LOG_WARN, tag, __VA_ARGS__))
  18. #define TINYUSDZLOGE(tag, ...) ((void)__android_log_print(ANDROID_LOG_ERROR, tag, __VA_ARGS__))
  19. #else
  20. #define TINYUSDZLOGT(tag, ...)
  21. #define TINYUSDZLOG0(tag, ...)
  22. #define TINYUSDZLOGD(tag, ...)
  23. #define TINYUSDZLOGI(tag, ...)
  24. #define TINYUSDZLOGW(tag, ...)
  25. #define TINYUSDZLOGE(tag, ...)
  26. #endif // #if defined(__ANDROID__)
  27. #if defined(TINYUSDZ_LOCAL_DEBUG_PRINT)
  28. #if defined(__ANDROID__)
  29. #if defined(ASSIMP_USD_VERBOSE_LOGS)
  30. // Works well but _extremely_ verbose
  31. #define DCOUT(x) \
  32. do { \
  33. std::stringstream ss; \
  34. ss << __FILE__ << ":" << __func__ << ":" \
  35. << std::to_string(__LINE__) << " " << x << "\n"; \
  36. TINYUSDZLOGE("tinyusdz", "%s", ss.str().c_str()); \
  37. } while (false)
  38. #else // defined(ASSIMP_USD_VERBOSE_LOGS)
  39. // Silent version
  40. #define DCOUT(x) \
  41. do { \
  42. std::stringstream ss; \
  43. ss << __FILE__ << ":" << __func__ << ":" \
  44. << std::to_string(__LINE__) << " " << x << "\n"; \
  45. } while (false)
  46. #endif // defined(ASSIMP_USD_VERBOSE_LOGS)
  47. #else // defined(__ANDROID__)
  48. #define DCOUT(x) \
  49. do { \
  50. std::cout << __FILE__ << ":" << __func__ << ":" \
  51. << std::to_string(__LINE__) << " " << x << "\n"; \
  52. } while (false)
  53. #endif // #if defined(__ANDROID__)
  54. #endif // #if defined(TINYUSDZ_LOCAL_DEBUG_PRINT)