diff options
author | Kaiyi Li <kaiyili@google.com> | 2021-10-28 15:49:11 -0700 |
---|---|---|
committer | Kaiyi Li <kaiyili@google.com> | 2021-10-29 07:44:07 -0700 |
commit | 2cb870f309a246b9d274a92a3e76bf0719f35515 (patch) | |
tree | 79f3997ca40dbc94bdd2d2a56ef861f779947692 /host-common | |
parent | a1bd19ce6927dcb26580604b2fda85090d4fdaca (diff) | |
download | vulkan-cereal-2cb870f309a246b9d274a92a3e76bf0719f35515.tar.gz |
Allow single parameter to be used for the ERR logging macro
Test: compile with ENABLE_GL_LOG defined and not defined
Change-Id: I29596a5d0e9f1def58429f9bef4ad6a824c1536a
Diffstat (limited to 'host-common')
-rw-r--r-- | host-common/logging.h | 20 |
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 |