aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/logging.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-28 02:16:46 -0800
committerChris Robinson <[email protected]>2018-12-28 12:29:05 -0800
commit983904bbdce5d0973c3cda143f499872e55013e3 (patch)
tree201052174329b177066707d683f9da085aa28af6 /Alc/logging.h
parentaff58265cb458b2ac2c42fef96383e9751d094d1 (diff)
Add a method to prefix logged function names
Diffstat (limited to 'Alc/logging.h')
-rw-r--r--Alc/logging.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/Alc/logging.h b/Alc/logging.h
index 41f64f77..ae70e598 100644
--- a/Alc/logging.h
+++ b/Alc/logging.h
@@ -18,22 +18,20 @@
#define DECL_FORMAT(x, y, z)
#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
extern FILE *gLogFile;
+constexpr inline const char *CurrentPrefix() noexcept { return ""; }
#if defined(__GNUC__) && !defined(_WIN32)
-#define AL_PRINT(T, MSG, ...) fprintf(gLogFile, "AL lib: %s %s: " MSG, T, __FUNCTION__ , ## __VA_ARGS__)
+#define AL_PRINT(T, MSG, ...) fprintf(gLogFile, "AL lib: %s %s%s: " MSG, T, CurrentPrefix(), __FUNCTION__ , ## __VA_ARGS__)
#else
-void al_print(const char *type, const char *func, const char *fmt, ...) DECL_FORMAT(printf, 3,4);
-#define AL_PRINT(T, ...) al_print((T), __FUNCTION__, __VA_ARGS__)
+void al_print(const char *type, const char *prefix, const char *func, const char *fmt, ...) DECL_FORMAT(printf, 4,5);
+#define AL_PRINT(T, ...) al_print((T), CurrentPrefix(), __FUNCTION__, __VA_ARGS__)
#endif
#ifdef __ANDROID__
#include <android/log.h>
-#define LOG_ANDROID(T, MSG, ...) __android_log_print(T, "openal", "AL lib: %s: " MSG, __FUNCTION__ , ## __VA_ARGS__)
+#define LOG_ANDROID(T, MSG, ...) __android_log_print(T, "openal", "AL lib: %s%s: " MSG, CurrentPrefix(), __FUNCTION__ , ## __VA_ARGS__)
#else
#define LOG_ANDROID(T, MSG, ...) ((void)0)
#endif
@@ -70,8 +68,4 @@ extern LogLevel gLogLevel;
LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \
} while(0)
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
#endif /* LOGGING_H */