Make a couple more operator bools explicit
[openal-soft.git] / core / logging.h
blob81465929c85a35ac5fdcb3a1ddbacacf44d9fe36
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;
20 #if !defined(_WIN32) && !defined(__ANDROID__)
21 #define TRACE(...) do { \
22 if UNLIKELY(gLogLevel >= LogLevel::Trace) \
23 fprintf(gLogFile, "[ALSOFT] (II) " __VA_ARGS__); \
24 } while(0)
26 #define WARN(...) do { \
27 if UNLIKELY(gLogLevel >= LogLevel::Warning) \
28 fprintf(gLogFile, "[ALSOFT] (WW) " __VA_ARGS__); \
29 } while(0)
31 #define ERR(...) do { \
32 if UNLIKELY(gLogLevel >= LogLevel::Error) \
33 fprintf(gLogFile, "[ALSOFT] (EE) " __VA_ARGS__); \
34 } while(0)
36 #else
38 #ifdef __USE_MINGW_ANSI_STDIO
39 [[gnu::format(gnu_printf,3,4)]]
40 #else
41 [[gnu::format(printf,3,4)]]
42 #endif
43 void al_print(LogLevel level, FILE *logfile, const char *fmt, ...);
45 #define TRACE(...) al_print(LogLevel::Trace, gLogFile, "[ALSOFT] (II) " __VA_ARGS__)
47 #define WARN(...) al_print(LogLevel::Warning, gLogFile, "[ALSOFT] (WW) " __VA_ARGS__)
49 #define ERR(...) al_print(LogLevel::Error, gLogFile, "[ALSOFT] (EE) " __VA_ARGS__)
50 #endif
52 #endif /* CORE_LOGGING_H */