diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/al/log.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/include/al/log.h b/include/al/log.h index fbd5e48..da3f21d 100644 --- a/include/al/log.h +++ b/include/al/log.h @@ -3,6 +3,10 @@ // https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html +#ifndef AL_LOG_SECTION +#define AL_LOG_SECTION NULL +#endif + #include <al/types.h> #include <al/lib.h> @@ -14,7 +18,8 @@ enum { AL_LOG_INFO = 0, AL_LOG_WARN, AL_LOG_ERROR, - AL_LOG_DEBUG + AL_LOG_DEBUG, + AL_LOG_TRACE }; void al_set_print(s32 (*print_func)(void *, u8, char *), void *userdata); @@ -25,12 +30,35 @@ s32 _al_logv(u8 level, const char *section, const char *name, const s32 line, co #define al_log(level, section, fmt, ...) _al_log(level, section, __LOCATION__, fmt, ##__VA_ARGS__) #define al_logv(level, section, fmt, args) _al_logv(level, section, __LOCATION__, fmt, args) +#define info(fmt, ...) al_log(AL_LOG_INFO, AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#define warn(fmt, ...) al_log(AL_LOG_WARN, AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#define error(fmt, ...) al_log(AL_LOG_ERROR, AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#ifdef _DEBUG_ +#define debug(fmt, ...) al_log(AL_LOG_DEBUG, AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#else +#define debug(fmt, ...) al_log_nop(AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#endif +#ifdef AL_LOG_ENABLE_TRACE +#define trace(fmt, ...) al_log(AL_LOG_TRACE, AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#else +#define trace(fmt, ...) al_log_nop(AL_LOG_SECTION, fmt, ##__VA_ARGS__) +#endif + +// TMP #define al_log_info(section, fmt, ...) al_log(AL_LOG_INFO, section, fmt, ##__VA_ARGS__) #define al_log_warn(section, fmt, ...) al_log(AL_LOG_WARN, section, fmt, ##__VA_ARGS__) #define al_log_error(section, fmt, ...) al_log(AL_LOG_ERROR, section, fmt, ##__VA_ARGS__) #ifdef _DEBUG_ #define al_log_debug(section, fmt, ...) al_log(AL_LOG_DEBUG, section, fmt, ##__VA_ARGS__) #else +#define al_log_debug(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__) +#endif +#ifdef AL_LOG_ENABLE_TRACE +#define al_log_trace(section, fmt, ...) al_log(AL_LOG_TRACE, section, fmt, ##__VA_ARGS__) +#else +#define al_log_trace(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__) +#endif + AL_UNUSED_FUNCTION_PUSH static inline s32 al_log_nop(const char *section, const char *fmt, ...) @@ -40,7 +68,4 @@ static inline s32 al_log_nop(const char *section, const char *fmt, ...) AL_UNUSED_FUNCTION_POP -#define al_log_debug(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__) -#endif - #endif // _AL_LOG_H |