🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. #ifndef CORE_LOGGING_H
  2. #define CORE_LOGGING_H
  3. #include <stdio.h>
  4. #include "opthelpers.h"
  5. enum class LogLevel {
  6. Disable,
  7. Error,
  8. Warning,
  9. Trace
  10. };
  11. extern LogLevel gLogLevel;
  12. extern FILE *gLogFile;
  13. #if !defined(_WIN32) && !defined(__ANDROID__)
  14. #define TRACE(...) do { \
  15. if UNLIKELY(gLogLevel >= LogLevel::Trace) \
  16. fprintf(gLogFile, "[ALSOFT] (II) " __VA_ARGS__); \
  17. } while(0)
  18. #define WARN(...) do { \
  19. if UNLIKELY(gLogLevel >= LogLevel::Warning) \
  20. fprintf(gLogFile, "[ALSOFT] (WW) " __VA_ARGS__); \
  21. } while(0)
  22. #define ERR(...) do { \
  23. if UNLIKELY(gLogLevel >= LogLevel::Error) \
  24. fprintf(gLogFile, "[ALSOFT] (EE) " __VA_ARGS__); \
  25. } while(0)
  26. #else
  27. #ifdef __USE_MINGW_ANSI_STDIO
  28. [[gnu::format(gnu_printf,3,4)]]
  29. #else
  30. [[gnu::format(printf,3,4)]]
  31. #endif
  32. void al_print(LogLevel level, FILE *logfile, const char *fmt, ...);
  33. #define TRACE(...) al_print(LogLevel::Trace, gLogFile, "[ALSOFT] (II) " __VA_ARGS__)
  34. #define WARN(...) al_print(LogLevel::Warning, gLogFile, "[ALSOFT] (WW) " __VA_ARGS__)
  35. #define ERR(...) al_print(LogLevel::Error, gLogFile, "[ALSOFT] (EE) " __VA_ARGS__)
  36. #endif
  37. #endif /* CORE_LOGGING_H */