diff options
author | Chris Robinson <[email protected]> | 2023-01-02 14:23:23 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-02 19:10:13 -0800 |
commit | 8054ccd8f91fee5aacb35e01decbecb67a8da8ce (patch) | |
tree | 5484bd8e99af4f0a26582565d48e19f04d9d6d0a /core/logging.h | |
parent | 52224f8bb87b724eb3c97605c37283f032937c9e (diff) |
Combine multiple al_printf definitions
And separate the log level prefix from the message.
Diffstat (limited to 'core/logging.h')
-rw-r--r-- | core/logging.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/core/logging.h b/core/logging.h index e90de661..2853afbd 100644 --- a/core/logging.h +++ b/core/logging.h @@ -16,37 +16,36 @@ extern LogLevel gLogLevel; extern FILE *gLogFile; +#ifdef __USE_MINGW_ANSI_STDIO +[[gnu::format(gnu_printf,3,4)]] +#else +[[gnu::format(printf,3,4)]] +#endif +void al_print(LogLevel level, FILE *logfile, const char *fmt, ...); #if !defined(_WIN32) && !defined(__ANDROID__) #define TRACE(...) do { \ if(gLogLevel >= LogLevel::Trace) [[unlikely]] \ - fprintf(gLogFile, "[ALSOFT] (II) " __VA_ARGS__); \ + al_print(LogLevel::Trace, gLogFile, __VA_ARGS__); \ } while(0) #define WARN(...) do { \ if(gLogLevel >= LogLevel::Warning) [[unlikely]] \ - fprintf(gLogFile, "[ALSOFT] (WW) " __VA_ARGS__); \ + al_print(LogLevel::Warning, gLogFile, __VA_ARGS__); \ } while(0) #define ERR(...) do { \ if(gLogLevel >= LogLevel::Error) [[unlikely]] \ - fprintf(gLogFile, "[ALSOFT] (EE) " __VA_ARGS__); \ + al_print(LogLevel::Error, gLogFile, __VA_ARGS__); \ } while(0) #else -#ifdef __USE_MINGW_ANSI_STDIO -[[gnu::format(gnu_printf,3,4)]] -#else -[[gnu::format(printf,3,4)]] -#endif -void al_print(LogLevel level, FILE *logfile, const char *fmt, ...); - -#define TRACE(...) al_print(LogLevel::Trace, gLogFile, "[ALSOFT] (II) " __VA_ARGS__) +#define TRACE(...) al_print(LogLevel::Trace, gLogFile, __VA_ARGS__) -#define WARN(...) al_print(LogLevel::Warning, gLogFile, "[ALSOFT] (WW) " __VA_ARGS__) +#define WARN(...) al_print(LogLevel::Warning, gLogFile, __VA_ARGS__) -#define ERR(...) al_print(LogLevel::Error, gLogFile, "[ALSOFT] (EE) " __VA_ARGS__) +#define ERR(...) al_print(LogLevel::Error, gLogFile, __VA_ARGS__) #endif #endif /* CORE_LOGGING_H */ |