aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2022-07-19 17:53:29 +0200
committerGitHub <[email protected]>2022-07-19 08:53:29 -0700
commit190652b71f4e0adbd6b38642f9b8ba6296ad1398 (patch)
tree99968751ca6653f8280b8d0feb082bb57880af21
parentc2243e891b7a42c2a231ca573281150e8cb3f2d4 (diff)
downloadcubeb-190652b71f4e0adbd6b38642f9b8ba6296ad1398.tar.gz
cubeb-190652b71f4e0adbd6b38642f9b8ba6296ad1398.zip
Don't print the file name and \n twice when logging asynchronously (#715)
Not the prettiest but it does the job. Thanks to @ashleyz we don't really care about checking the log level here, it's checked ahead of time, which is nice because we don't want to carry it in the async log payload.
-rw-r--r--src/cubeb_log.cpp2
-rw-r--r--src/cubeb_log.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/cubeb_log.cpp b/src/cubeb_log.cpp
index bd34af1..16aed6e 100644
--- a/src/cubeb_log.cpp
+++ b/src/cubeb_log.cpp
@@ -72,7 +72,7 @@ public:
while (true) {
cubeb_log_message msg;
while (msg_queue.dequeue(&msg, 1)) {
- LOGV("%s", msg.get());
+ LOG_INTERNAL_NO_FORMAT(CUBEB_LOG_NORMAL, "%s", msg.get());
}
#ifdef _WIN32
Sleep(CUBEB_LOG_BATCH_PRINT_INTERVAL_MS);
diff --git a/src/cubeb_log.h b/src/cubeb_log.h
index 041ec75..fcc9c89 100644
--- a/src/cubeb_log.h
+++ b/src/cubeb_log.h
@@ -44,6 +44,13 @@ cubeb_async_log_reset_threads(void);
#define LOGV(msg, ...) LOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__)
#define LOG(msg, ...) LOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__)
+#define LOG_INTERNAL_NO_FORMAT(level, fmt, ...) \
+ do { \
+ if (g_cubeb_log_callback && level <= g_cubeb_log_level) { \
+ g_cubeb_log_callback(fmt, __VA_ARGS__); \
+ } \
+ } while (0)
+
#define LOG_INTERNAL(level, fmt, ...) \
do { \
if (g_cubeb_log_callback && level <= g_cubeb_log_level) { \