summaryrefslogtreecommitdiff
path: root/include/al
diff options
context:
space:
mode:
Diffstat (limited to 'include/al')
-rw-r--r--include/al/log.h41
1 files changed, 15 insertions, 26 deletions
diff --git a/include/al/log.h b/include/al/log.h
index 2fb0c26..91f87bb 100644
--- a/include/al/log.h
+++ b/include/al/log.h
@@ -3,13 +3,17 @@
// 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>
+AL_IGNORE_WARNING("-Wunused-variable")
+#ifndef AL_LOG_SECTION
+static const char *AL_LOG_SECTION_NAME = "";
+#else
+static const char *AL_LOG_SECTION_NAME = AL_LOG_SECTION;
+#endif
+AL_IGNORE_WARNING_END
+
#define __LOCATION__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__
#define AL_LOG_MESSAGE_SIZE 256u
@@ -30,33 +34,18 @@ 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__)
+#define log_info(fmt, ...) al_log(AL_LOG_INFO, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
+#define log_warn(fmt, ...) al_log(AL_LOG_WARN, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
+#define log_error(fmt, ...) al_log(AL_LOG_ERROR, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
#ifdef _DEBUG_
-#define al_log_debug(section, fmt, ...) al_log(AL_LOG_DEBUG, section, fmt, ##__VA_ARGS__)
+#define log_debug(fmt, ...) al_log(AL_LOG_DEBUG, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
#else
-#define al_log_debug(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__)
+#define log_debug(fmt, ...) al_log_nop(AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
#endif
#ifdef AL_LOG_ENABLE_TRACE
-#define al_log_trace(section, fmt, ...) al_log(AL_LOG_TRACE, section, fmt, ##__VA_ARGS__)
+#define log_trace(fmt, ...) al_log(AL_LOG_TRACE, AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
#else
-#define al_log_trace(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__)
+#define log_trace(fmt, ...) al_log_nop(AL_LOG_SECTION_NAME, fmt, ##__VA_ARGS__)
#endif
static inline s32 al_log_nop(const char *section, const char *fmt, ...)