log.h 1.1 KB

123456789101112131415161718192021222324
  1. #ifndef LOG_H_
  2. #define LOG_H_
  3. #include <stddef.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #define SE_LOG(str) se_log_with_tag(false, __FILE__, __LINE__, "LOG", (str))
  7. #define SE_LOGF(fmt, ...) se_logf_with_tag(false, __FILE__, __LINE__, "LOG", (fmt), __VA_ARGS__)
  8. #define SE_LOG_ERROR(str) se_log_with_tag(true, __FILE__, __LINE__, "ERROR", (str))
  9. #define SE_LOG_ERRORF(fmt, ...) se_logf_with_tag(true, __FILE__, __LINE__, "ERROR", (fmt), __VA_ARGS__)
  10. #define SE_LOG_FATAL(str) SE_LOG_ERROR(str); exit(-1)
  11. #define SE_LOG_FATALF(fmt, ...) SE_LOG_ERRORF(fmt, __VA_ARGS__); exit(-1)
  12. #define SE_LOG_FATAL_TODO(str) se_log_with_tag(true, __FILE__, __LINE__, "FATAL TODO", (str)); exit(-1)
  13. #define SE_LOG_FATAL_TODOF(fmt, ...) se_logf_with_tag(true, __FILE__, __LINE__, "FATAL TODO", (fmt), __VA_ARGS__); exit(-1)
  14. void se_log_out_set(FILE *log_out, FILE *log_err_out);
  15. void se_log_with_tag(const bool is_error, char* file_name, size_t line, const char* tag, char* str);
  16. void se_logf_with_tag(const bool is_error, char* file_name, size_t line, const char* tag, char* fmt, ...);
  17. #endif // LOG_H_