diff options
author | az <[email protected]> | 2022-07-18 09:45:39 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-18 09:45:39 -0700 |
commit | c2243e891b7a42c2a231ca573281150e8cb3f2d4 (patch) | |
tree | fd7f468835fd0dfeeb28ffe4e02ac4f6514b3009 | |
parent | c644de9681c26da9da0926299e0d8931f8da1546 (diff) | |
download | cubeb-c2243e891b7a42c2a231ca573281150e8cb3f2d4.tar.gz cubeb-c2243e891b7a42c2a231ca573281150e8cb3f2d4.zip |
Check log level in asynchronous logging macros before printing (#714)
Added `ALOG` macro and updated `ALOGV` for use with asynchronous logging. Both macros should now verify log level.
-rw-r--r-- | src/cubeb_log.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cubeb_log.h b/src/cubeb_log.h index 4380da4..041ec75 100644 --- a/src/cubeb_log.h +++ b/src/cubeb_log.h @@ -52,11 +52,16 @@ cubeb_async_log_reset_threads(void); } \ } while (0) -/* Asynchronous verbose logging, to log in real-time callbacks. */ -/* Should not be used on android due to the use of global/static variables. */ -#define ALOGV(fmt, ...) \ +#define ALOG_INTERNAL(level, fmt, ...) \ do { \ - cubeb_async_log(fmt, ##__VA_ARGS__); \ + if (level <= g_cubeb_log_level) { \ + cubeb_async_log(fmt, ##__VA_ARGS__); \ + } \ } while (0) +/* Asynchronous logging macros to log in real-time callbacks. */ +/* Should not be used on android due to the use of global/static variables. */ +#define ALOGV(msg, ...) ALOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__) +#define ALOG(msg, ...) ALOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__) + #endif // CUBEB_LOG |