aboutsummaryrefslogtreecommitdiffstats
path: root/alc/logging.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
committerSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
commit4df06c6894b39af5bf4681c0acf0c1c080084c80 (patch)
tree2505eb6e3b5798db34033c4cac2d4613bf6bda44 /alc/logging.h
parent8915501ed02eac2b3bce9a7fc06cb1ab562901c3 (diff)
parentc0cf323e1d56ce605e90927324d2fdafcfbb564a (diff)
merge v1.20.0
Diffstat (limited to 'alc/logging.h')
-rw-r--r--alc/logging.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/alc/logging.h b/alc/logging.h
new file mode 100644
index 00000000..ec6023a5
--- /dev/null
+++ b/alc/logging.h
@@ -0,0 +1,59 @@
+#ifndef LOGGING_H
+#define LOGGING_H
+
+#include <stdio.h>
+
+#include "opthelpers.h"
+
+
+#ifdef __GNUC__
+#define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z))))
+#else
+#define DECL_FORMAT(x, y, z)
+#endif
+
+
+extern FILE *gLogFile;
+
+void al_print(FILE *logfile, const char *fmt, ...) DECL_FORMAT(printf, 2,3);
+#if !defined(_WIN32)
+#define AL_PRINT fprintf
+#else
+#define AL_PRINT al_print
+#endif
+
+#ifdef __ANDROID__
+#include <android/log.h>
+#define LOG_ANDROID(T, ...) __android_log_print(T, "openal", "AL lib: " __VA_ARGS__)
+#else
+#define LOG_ANDROID(T, ...) ((void)0)
+#endif
+
+enum LogLevel {
+ NoLog,
+ LogError,
+ LogWarning,
+ LogTrace,
+ LogRef
+};
+extern LogLevel gLogLevel;
+
+#define TRACE(...) do { \
+ if UNLIKELY(gLogLevel >= LogTrace) \
+ AL_PRINT(gLogFile, "AL lib: (II) " __VA_ARGS__); \
+ LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
+} while(0)
+
+#define WARN(...) do { \
+ if UNLIKELY(gLogLevel >= LogWarning) \
+ AL_PRINT(gLogFile, "AL lib: (WW) " __VA_ARGS__); \
+ LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
+} while(0)
+
+#define ERR(...) do { \
+ if UNLIKELY(gLogLevel >= LogError) \
+ AL_PRINT(gLogFile, "AL lib: (EE) " __VA_ARGS__); \
+ LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
+} while(0)
+
+#endif /* LOGGING_H */