Avoid class templates for the POPCNT64/CTZ64 macros
[openal-soft.git] / alc / logging.h
blob1077f08fdc2aa18e3210a07bb17126e2fb67f3c4
1 #ifndef LOGGING_H
2 #define LOGGING_H
4 #include <stdio.h>
6 #include "opthelpers.h"
9 extern FILE *gLogFile;
11 [[gnu::format(printf,2,3)]] void al_print(FILE *logfile, const char *fmt, ...);
12 #if !defined(_WIN32)
13 #define AL_PRINT fprintf
14 #else
15 #define AL_PRINT al_print
16 #endif
18 #ifdef __ANDROID__
19 #include <android/log.h>
20 #define LOG_ANDROID(T, ...) __android_log_print(T, "openal", "AL lib: " __VA_ARGS__)
21 #else
22 #define LOG_ANDROID(T, ...) ((void)0)
23 #endif
25 enum LogLevel {
26 NoLog,
27 LogError,
28 LogWarning,
29 LogTrace,
30 LogRef
32 extern LogLevel gLogLevel;
34 #define TRACE(...) do { \
35 if UNLIKELY(gLogLevel >= LogTrace) \
36 AL_PRINT(gLogFile, "AL lib: (II) " __VA_ARGS__); \
37 LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
38 } while(0)
40 #define WARN(...) do { \
41 if UNLIKELY(gLogLevel >= LogWarning) \
42 AL_PRINT(gLogFile, "AL lib: (WW) " __VA_ARGS__); \
43 LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
44 } while(0)
46 #define ERR(...) do { \
47 if UNLIKELY(gLogLevel >= LogError) \
48 AL_PRINT(gLogFile, "AL lib: (EE) " __VA_ARGS__); \
49 LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
50 } while(0)
52 #endif /* LOGGING_H */