aboutsummaryrefslogtreecommitdiffstats
path: root/core/logging.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-07-02 13:21:48 -0700
committerChris Robinson <[email protected]>2023-07-02 13:21:48 -0700
commit65d0196db6f09292c3eb3c106d6ca543ad937e82 (patch)
tree042aa7c0c10a2a0bbdd6a067b2778278c90fefc6 /core/logging.h
parent548f7ad80abc253a38171b7e4eb1c84a6b179a41 (diff)
Add a function to set a callback for log messages
Diffstat (limited to 'core/logging.h')
-rw-r--r--core/logging.h25
1 files changed, 6 insertions, 19 deletions
diff --git a/core/logging.h b/core/logging.h
index c99c4e45..06b7cdde 100644
--- a/core/logging.h
+++ b/core/logging.h
@@ -16,6 +16,12 @@ extern LogLevel gLogLevel;
extern FILE *gLogFile;
+
+using LogCallbackFunc = void(*)(void *userptr, char level, const char *message, int length) noexcept;
+
+void al_set_log_callback(LogCallbackFunc callback, void *userptr);
+
+
#ifdef __USE_MINGW_ANSI_STDIO
[[gnu::format(gnu_printf,2,3)]]
#else
@@ -23,29 +29,10 @@ extern FILE *gLogFile;
#endif
void al_print(LogLevel level, const char *fmt, ...);
-#if (!defined(_WIN32) || defined(NDEBUG)) && !defined(__ANDROID__)
-#define TRACE(...) do { \
- if(gLogLevel >= LogLevel::Trace) UNLIKELY \
- al_print(LogLevel::Trace, __VA_ARGS__); \
-} while(0)
-
-#define WARN(...) do { \
- if(gLogLevel >= LogLevel::Warning) UNLIKELY \
- al_print(LogLevel::Warning, __VA_ARGS__); \
-} while(0)
-
-#define ERR(...) do { \
- if(gLogLevel >= LogLevel::Error) UNLIKELY \
- al_print(LogLevel::Error, __VA_ARGS__); \
-} while(0)
-
-#else
-
#define TRACE(...) al_print(LogLevel::Trace, __VA_ARGS__)
#define WARN(...) al_print(LogLevel::Warning, __VA_ARGS__)
#define ERR(...) al_print(LogLevel::Error, __VA_ARGS__)
-#endif
#endif /* CORE_LOGGING_H */