diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/msg.c | 8 | ||||
-rw-r--r-- | common/msg.h | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/common/msg.c b/common/msg.c index cb41ea4168..e35b953f7d 100644 --- a/common/msg.c +++ b/common/msg.c @@ -127,19 +127,19 @@ static void update_loglevel(struct mp_log *log) pthread_mutex_unlock(&mp_msg_lock); } -// Return whether the message at this verbosity level would be actually printed. +// Get the current effective msg level. // Thread-safety: see mp_msg(). -bool mp_msg_test(struct mp_log *log, int lev) +int mp_msg_level(struct mp_log *log) { struct mp_log_root *root = log->root; if (!root) - return false; + return -1; if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) != atomic_load_explicit(&root->reload_counter, memory_order_relaxed)) { update_loglevel(log); } - return lev <= log->level; + return log->level; } // Reposition cursor and clear lines for outputting the status line. In certain diff --git a/common/msg.h b/common/msg.h index 21228870f4..635a85191f 100644 --- a/common/msg.h +++ b/common/msg.h @@ -52,7 +52,12 @@ void mp_msg(struct mp_log *log, int lev, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va); -bool mp_msg_test(struct mp_log *log, int lev); +int mp_msg_level(struct mp_log *log); + +static inline bool mp_msg_test(struct mp_log *log, int lev) +{ + return lev <= mp_msg_level(log); +} // Convenience macros. #define mp_fatal(log, ...) mp_msg(log, MSGL_FATAL, __VA_ARGS__) |