summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-04-17 09:45:12 -0400
committerAndrew Opalach <andrew@akon.city> 2025-04-17 09:50:50 -0400
commit85fb9ba380540ce24f1c99f21c14653459161a63 (patch)
treeca41e8f4625e8945a5fcd7b9538a767aec3c9f4b
parente5df584d6d8dc8c9036210943e42e43b30ac3def (diff)
downloadlibalabaster-85fb9ba380540ce24f1c99f21c14653459161a63.tar.gz
libalabaster-85fb9ba380540ce24f1c99f21c14653459161a63.tar.bz2
libalabaster-85fb9ba380540ce24f1c99f21c14653459161a63.zip
log: Remove al_ prefix and pre-define section name
log.h is now included like: #define AL_LOG_SECTION "<section_name>" #include <al/log.h> Signed-off-by: Andrew Opalach <andrew@akon.city>
-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, ...)