openal-soft/Alc/logging.h

65 lines
2.0 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"
#ifdef __GNUC__
#define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z))))
#else
#define DECL_FORMAT(x, y, z)
#endif
2018-03-09 17:24:03 -08:00
extern FILE *gLogFile;
2019-06-18 22:57:48 -07:00
void al_print(FILE *logfile, const char *fmt, ...) DECL_FORMAT(printf, 2,3);
#if !defined(_WIN32)
#define AL_PRINT(T, ...) fprintf(gLogFile, "AL lib: " T " " __VA_ARGS__)
#else
2019-06-18 22:57:48 -07:00
#define AL_PRINT(T, ...) al_print(gLogFile, "AL lib: " T " " __VA_ARGS__)
#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 TRACEREF(...) do { \
2019-01-07 01:13:06 -08:00
if(UNLIKELY(gLogLevel >= LogRef)) \
AL_PRINT("(--)", __VA_ARGS__); \
} while(0)
#define TRACE(...) do { \
2019-01-07 01:13:06 -08:00
if(UNLIKELY(gLogLevel >= LogTrace)) \
AL_PRINT("(II)", __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \
} while(0)
#define WARN(...) do { \
2019-01-07 01:13:06 -08:00
if(UNLIKELY(gLogLevel >= LogWarning)) \
AL_PRINT("(WW)", __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \
} while(0)
#define ERR(...) do { \
2019-01-07 01:13:06 -08:00
if(UNLIKELY(gLogLevel >= LogError)) \
AL_PRINT("(EE)", __VA_ARGS__); \
LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
} while(0)
#endif /* LOGGING_H */