From 062c93b1f718730c71bc4d2a1e53e0107dd236ad Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 20 Dec 2019 21:29:18 +0100 Subject: Route all backend debug logging through a macro --- midimonster.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index eb19409..5844bb9 100644 --- a/midimonster.h +++ b/midimonster.h @@ -10,6 +10,11 @@ #define MIDIMONSTER_VERSION "v0.3-dist" #endif +/* Set backend name if unset */ +#ifndef BACKEND_NAME + #define BACKEND_NAME "unspec" +#endif + /* API call attributes and visibilities */ #ifndef MM_API #ifdef _WIN32 @@ -37,13 +42,15 @@ /* Debug messages only compile in when DEBUG is set */ #ifdef DEBUG - #define DBGPF(format, ...) fprintf(stderr, (format), __VA_ARGS__) - #define DBG(message) fprintf(stderr, "%s", (message)) + #define DBGPF(format, ...) fprintf(stderr, "debug/%s\t" format "\n", (BACKEND_NAME), __VA_ARGS__) #else #define DBGPF(format, ...) - #define DBG(message) #endif +/* Log messages should be routed through these macros to ensure interoperability with different core implementations */ +#define LOGPF(format, ...) fprintf(stderr, "%s\t" format "\n", (BACKEND_NAME), __VA_ARGS__) +#define LOG(message) fprintf(stderr, "%s\t%s\n", (BACKEND_NAME), (message)) + /* Stop compilation if the build system reports an error */ #ifdef BUILD_ERROR #error The build system reported an error, compilation stopped. Refer to the invocation for this compilation unit for more information. -- cgit v1.2.3