luat_log.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef LUAT_LOG_H
  2. #define LUAT_LOG_H
  3. #include "luat_base.h"
  4. #define LUAT_LOG_DEBUG 1
  5. #define LUAT_LOG_INFO 2
  6. #define LUAT_LOG_WARN 3
  7. #define LUAT_LOG_ERROR 4
  8. #define LUAT_LOG_CLOSE 7
  9. // void luat_print(const char* _str);
  10. void luat_nprint(char *s, size_t l);
  11. void luat_log_write(char *s, size_t l);
  12. // #define luat_nprint luat_log_write
  13. void luat_log_set_uart_port(int port);
  14. uint8_t luat_log_get_uart_port(void);
  15. void luat_log_set_level(int level);
  16. int luat_log_get_level(void);
  17. #ifdef LUAT_USE_LOG2
  18. #define LLOGE(format, ...) luat_log_printf(LUAT_LOG_ERROR, "E/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
  19. #define LLOGW(format, ...) luat_log_printf(LUAT_LOG_WARN, "W/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
  20. #define LLOGI(format, ...) luat_log_printf(LUAT_LOG_INFO, "I/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
  21. #define LLOGD(format, ...) luat_log_printf(LUAT_LOG_DEBUG, "D/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
  22. void luat_log_printf(int level, const char* _fmt, ...);
  23. #else
  24. void luat_log_log(int level, const char* tag, const char* _fmt, ...);
  25. #define LLOGE(format, ...) luat_log_log(LUAT_LOG_ERROR, LUAT_LOG_TAG, format, ##__VA_ARGS__)
  26. #define LLOGW(format, ...) luat_log_log(LUAT_LOG_WARN, LUAT_LOG_TAG, format, ##__VA_ARGS__)
  27. #define LLOGI(format, ...) luat_log_log(LUAT_LOG_INFO, LUAT_LOG_TAG, format, ##__VA_ARGS__)
  28. #define LLOGD(format, ...) luat_log_log(LUAT_LOG_DEBUG, LUAT_LOG_TAG, format, ##__VA_ARGS__)
  29. #define luat_log_error(XTAG, format, ...) luat_log_log(LUAT_LOG_ERROR, XTAG, format, ##__VA_ARGS__)
  30. #define luat_log_warn(XTAG, format, ...) luat_log_log(LUAT_LOG_WARN, XTAG, format, ##__VA_ARGS__)
  31. #define luat_log_info(XTAG, format, ...) luat_log_log(LUAT_LOG_INFO, XTAG, format, ##__VA_ARGS__)
  32. #define luat_log_debug(XTAG, format, ...) luat_log_log(LUAT_LOG_DEBUG, XTAG, format, ##__VA_ARGS__)
  33. void luat_log_dump(const char* tag, void* ptr, size_t len);
  34. #define LLOGDUMP(ptr,len) luat_log_dump(LUAT_LOG_TAG, ptr, len)
  35. #endif
  36. #endif