Log the buffer format when queueing mismatched buffers
[openal-soft.git] / core / logging.h
blobf4b6ab56278714be881f1b4d557f42da0bc8829b
1 #ifndef CORE_LOGGING_H
2 #define CORE_LOGGING_H
4 #include <stdio.h>
6 #include "opthelpers.h"
9 enum class LogLevel {
10 Disable,
11 Error,
12 Warning,
13 Trace
15 extern LogLevel gLogLevel;
17 extern FILE *gLogFile;
19 #ifdef __USE_MINGW_ANSI_STDIO
20 [[gnu::format(gnu_printf,3,4)]]
21 #else
22 [[gnu::format(printf,3,4)]]
23 #endif
24 void al_print(LogLevel level, FILE *logfile, const char *fmt, ...);
26 #if (!defined(_WIN32) || defined(NDEBUG)) && !defined(__ANDROID__)
27 #define TRACE(...) do { \
28 if(gLogLevel >= LogLevel::Trace) UNLIKELY \
29 al_print(LogLevel::Trace, gLogFile, __VA_ARGS__); \
30 } while(0)
32 #define WARN(...) do { \
33 if(gLogLevel >= LogLevel::Warning) UNLIKELY \
34 al_print(LogLevel::Warning, gLogFile, __VA_ARGS__); \
35 } while(0)
37 #define ERR(...) do { \
38 if(gLogLevel >= LogLevel::Error) UNLIKELY \
39 al_print(LogLevel::Error, gLogFile, __VA_ARGS__); \
40 } while(0)
42 #else
44 #define TRACE(...) al_print(LogLevel::Trace, gLogFile, __VA_ARGS__)
46 #define WARN(...) al_print(LogLevel::Warning, gLogFile, __VA_ARGS__)
48 #define ERR(...) al_print(LogLevel::Error, gLogFile, __VA_ARGS__)
49 #endif
51 #endif /* CORE_LOGGING_H */