Remove redundant void argument list in function def
[openal-soft.git] / Alc / logging.h
blob6c2c1c9428077adc719b8509fc019e0df00e7855
1 #ifndef LOGGING_H
2 #define LOGGING_H
4 #include <stdio.h>
6 #include "opthelpers.h"
9 #if defined(_WIN64)
10 #define SZFMT "%I64u"
11 #elif defined(_WIN32)
12 #define SZFMT "%u"
13 #else
14 #define SZFMT "%zu"
15 #endif
17 #ifdef __GNUC__
18 #define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z))))
19 #else
20 #define DECL_FORMAT(x, y, z)
21 #endif
24 extern FILE *gLogFile;
26 constexpr inline const char *CurrentPrefix() noexcept { return ""; }
27 #if defined(__GNUC__) && !defined(_WIN32)
28 #define AL_PRINT(T, MSG, ...) fprintf(gLogFile, "AL lib: %s %s%s: " MSG, T, CurrentPrefix(), __FUNCTION__ , ## __VA_ARGS__)
29 #else
30 void al_print(const char *type, const char *prefix, const char *func, const char *fmt, ...) DECL_FORMAT(printf, 4,5);
31 #define AL_PRINT(T, ...) al_print((T), CurrentPrefix(), __FUNCTION__, __VA_ARGS__)
32 #endif
34 #ifdef __ANDROID__
35 #include <android/log.h>
36 #define LOG_ANDROID(T, MSG, ...) __android_log_print(T, "openal", "AL lib: %s%s: " MSG, CurrentPrefix(), __FUNCTION__ , ## __VA_ARGS__)
37 #else
38 #define LOG_ANDROID(T, MSG, ...) ((void)0)
39 #endif
41 enum LogLevel {
42 NoLog,
43 LogError,
44 LogWarning,
45 LogTrace,
46 LogRef
48 extern LogLevel gLogLevel;
50 #define TRACEREF(...) do { \
51 if(UNLIKELY(gLogLevel >= LogRef)) \
52 AL_PRINT("(--)", __VA_ARGS__); \
53 } while(0)
55 #define TRACE(...) do { \
56 if(UNLIKELY(gLogLevel >= LogTrace)) \
57 AL_PRINT("(II)", __VA_ARGS__); \
58 LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
59 } while(0)
61 #define WARN(...) do { \
62 if(UNLIKELY(gLogLevel >= LogWarning)) \
63 AL_PRINT("(WW)", __VA_ARGS__); \
64 LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
65 } while(0)
67 #define ERR(...) do { \
68 if(UNLIKELY(gLogLevel >= LogError)) \
69 AL_PRINT("(EE)", __VA_ARGS__); \
70 LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
71 } while(0)
73 #endif /* LOGGING_H */