openal-soft/alc/logging.h

53 lines
1.5 KiB
C
Raw Normal View History

#ifndef LOGGING_H
#define LOGGING_H
#include <stdio.h>
2019-01-07 01:13:06 -08:00
#include "opthelpers.h"
extern FILE *gLogFile;
2020-04-13 23:19:11 -07:00
[[gnu::format(printf,2,3)]] void al_print(FILE *logfile, const char *fmt, ...);
#if !defined(_WIN32)
2019-10-08 00:21:21 -07:00
#define AL_PRINT fprintf
#else
2019-10-08 00:21:21 -07:00
#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
2020-09-28 00:40:30 -07:00
enum class LogLevel {
Disable,
Error,
Warning,
Trace,
Ref
};
extern LogLevel gLogLevel;
#define TRACE(...) do { \
2020-09-28 00:40:30 -07:00
if UNLIKELY(gLogLevel >= LogLevel::Trace) \
2019-10-08 00:21:21 -07:00
AL_PRINT(gLogFile, "AL lib: (II) " __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
} while(0)
#define WARN(...) do { \
2020-09-28 00:40:30 -07:00
if UNLIKELY(gLogLevel >= LogLevel::Warning) \
2019-10-08 00:21:21 -07:00
AL_PRINT(gLogFile, "AL lib: (WW) " __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
} while(0)
#define ERR(...) do { \
2020-09-28 00:40:30 -07:00
if UNLIKELY(gLogLevel >= LogLevel::Error) \
2019-10-08 00:21:21 -07:00
AL_PRINT(gLogFile, "AL lib: (EE) " __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
} while(0)
#endif /* LOGGING_H */