Avoid static constexpr for arrays iterated over at run-time
[openal-soft.git] / alc / logging.h
blobec6023a5ed8726899de3a2ccf6da551de55ff02c
1 #ifndef LOGGING_H
2 #define LOGGING_H
4 #include <stdio.h>
6 #include "opthelpers.h"
9 #ifdef __GNUC__
10 #define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z))))
11 #else
12 #define DECL_FORMAT(x, y, z)
13 #endif
16 extern FILE *gLogFile;
18 void al_print(FILE *logfile, const char *fmt, ...) DECL_FORMAT(printf, 2,3);
19 #if !defined(_WIN32)
20 #define AL_PRINT fprintf
21 #else
22 #define AL_PRINT al_print
23 #endif
25 #ifdef __ANDROID__
26 #include <android/log.h>
27 #define LOG_ANDROID(T, ...) __android_log_print(T, "openal", "AL lib: " __VA_ARGS__)
28 #else
29 #define LOG_ANDROID(T, ...) ((void)0)
30 #endif
32 enum LogLevel {
33 NoLog,
34 LogError,
35 LogWarning,
36 LogTrace,
37 LogRef
39 extern LogLevel gLogLevel;
41 #define TRACE(...) do { \
42 if UNLIKELY(gLogLevel >= LogTrace) \
43 AL_PRINT(gLogFile, "AL lib: (II) " __VA_ARGS__); \
44 LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
45 } while(0)
47 #define WARN(...) do { \
48 if UNLIKELY(gLogLevel >= LogWarning) \
49 AL_PRINT(gLogFile, "AL lib: (WW) " __VA_ARGS__); \
50 LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
51 } while(0)
53 #define ERR(...) do { \
54 if UNLIKELY(gLogLevel >= LogError) \
55 AL_PRINT(gLogFile, "AL lib: (EE) " __VA_ARGS__); \
56 LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
57 } while(0)
59 #endif /* LOGGING_H */