diff options
author | Chris Robinson <[email protected]> | 2020-09-28 11:34:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-28 11:34:24 -0700 |
commit | f02bc1354d406707619c3f4704e06c9d15b24f63 (patch) | |
tree | ebd59b653f71c3b00a0df2e7217cd3a17cdcd519 /alc/logging.h | |
parent | da29489ead3ecfc269a220a22ee117d93bed23a6 (diff) |
Rework logging a little
Use OutputDebugStringW on Windows in addition to the log file
Avoid duplicate formatter parsing with Android
Diffstat (limited to 'alc/logging.h')
-rw-r--r-- | alc/logging.h | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/alc/logging.h b/alc/logging.h index 77593779..4b015814 100644 --- a/alc/logging.h +++ b/alc/logging.h @@ -6,22 +6,6 @@ #include "opthelpers.h" -extern FILE *gLogFile; - -[[gnu::format(printf,2,3)]] void al_print(FILE *logfile, const char *fmt, ...); -#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 class LogLevel { Disable, Error, @@ -31,22 +15,34 @@ enum class LogLevel { }; extern LogLevel gLogLevel; +extern FILE *gLogFile; + + +#if !defined(_WIN32) && !defined(__ANDROID__) #define TRACE(...) do { \ if UNLIKELY(gLogLevel >= LogLevel::Trace) \ - AL_PRINT(gLogFile, "AL lib: (II) " __VA_ARGS__); \ - LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \ + fprintf(gLogFile, "[ALSOFT] (II) " __VA_ARGS__); \ } while(0) #define WARN(...) do { \ if UNLIKELY(gLogLevel >= LogLevel::Warning) \ - AL_PRINT(gLogFile, "AL lib: (WW) " __VA_ARGS__); \ - LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \ + fprintf(gLogFile, "[ALSOFT] (WW) " __VA_ARGS__); \ } while(0) #define ERR(...) do { \ if UNLIKELY(gLogLevel >= LogLevel::Error) \ - AL_PRINT(gLogFile, "AL lib: (EE) " __VA_ARGS__); \ - LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \ + fprintf(gLogFile, "[ALSOFT] (EE) " __VA_ARGS__); \ } while(0) +#else + +[[gnu::format(printf,3,4)]] void al_print(LogLevel level, FILE *logfile, const char *fmt, ...); + +#define TRACE(...) al_print(LogLevel::Trace, gLogFile, "[ALSOFT] (II) " __VA_ARGS__) + +#define WARN(...) al_print(LogLevel::Warning, gLogFile, "[ALSOFT] (WW) " __VA_ARGS__) + +#define ERR(...) al_print(LogLevel::Error, gLogFile, "[ALSOFT] (EE) " __VA_ARGS__) +#endif + #endif /* LOGGING_H */ |