]> git.tdb.fi Git - ext/openal.git/blob - core/logging.h
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / core / logging.h
1 #ifndef CORE_LOGGING_H
2 #define CORE_LOGGING_H
3
4 #include <stdio.h>
5
6 #include "opthelpers.h"
7
8
9 enum class LogLevel {
10     Disable,
11     Error,
12     Warning,
13     Trace
14 };
15 extern LogLevel gLogLevel;
16
17 extern FILE *gLogFile;
18
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, ...);
25
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)
31
32 #define WARN(...) do {                                                        \
33     if(gLogLevel >= LogLevel::Warning) UNLIKELY                               \
34         al_print(LogLevel::Warning, gLogFile, __VA_ARGS__);                   \
35 } while(0)
36
37 #define ERR(...) do {                                                         \
38     if(gLogLevel >= LogLevel::Error) UNLIKELY                                 \
39         al_print(LogLevel::Error, gLogFile, __VA_ARGS__);                     \
40 } while(0)
41
42 #else
43
44 #define TRACE(...) al_print(LogLevel::Trace, gLogFile, __VA_ARGS__)
45
46 #define WARN(...) al_print(LogLevel::Warning, gLogFile, __VA_ARGS__)
47
48 #define ERR(...) al_print(LogLevel::Error, gLogFile, __VA_ARGS__)
49 #endif
50
51 #endif /* CORE_LOGGING_H */