Skip to content

Commit

Permalink
Don't print the file name and \n twice when logging asynchronously (#715
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
padenot committed Jul 19, 2022
1 parent c2243e8 commit 190652b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cubeb_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class cubeb_async_logger {
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);
Expand Down
7 changes: 7 additions & 0 deletions src/cubeb_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) { \
Expand Down

0 comments on commit 190652b

Please sign in to comment.