summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--host-common/logging.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/host-common/logging.h b/host-common/logging.h
index 70bd61a3..2701b8c3 100644
--- a/host-common/logging.h
+++ b/host-common/logging.h
@@ -2,11 +2,25 @@
#include <cstdio>
+#ifdef _MSC_VER
+#define GFXSTREAM_LOG(file, fmt, ...) \
+ fprintf(file, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
+#elif defined(__GNUC__) || defined(__clang__)
+#define GFXSTREAM_LOG(file, fmt, ...) \
+ fprintf(file, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__)
+#else
+#define GFXSTREAM_LOG(...) ((void)0)
+#endif
+
//#define ENABLE_GL_LOG 1
#if defined(ENABLE_GL_LOG)
-#define GL_LOG(fmt, args ...) fprintf(stderr, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ## args)
+#define GL_LOG(fmt, ...) GFXSTREAM_LOG(stderr, fmt, __VA_ARGS__)
#else
-#define GL_LOG(...)
+#define GL_LOG(...) ((void)0)
#endif
-#define ERR(fmt, args ...) fprintf(stderr, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ## args)
+#define ERR(...) \
+ do { \
+ GFXSTREAM_LOG(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ } while (0) \ No newline at end of file