summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-16 21:31:54 +0100
committerwm4 <wm4@nowhere>2019-12-16 21:31:54 +0100
commit5d9aa72f25a1193f6406d8ecda92c8a2142923ef (patch)
treeb72d6975e16e065a7b27ea4250820c94c4270376
parentd07b7f068db56aa5fa7cf16b9d077721ff0a8452 (diff)
downloadmpv-5d9aa72f25a1193f6406d8ecda92c8a2142923ef.tar.bz2
mpv-5d9aa72f25a1193f6406d8ecda92c8a2142923ef.tar.xz
msg: fix "terminal-default" logging mode
console.lua uses "terminal-default" logging, which is supposed to return all messages logged to the terminal to the API. Internally, this is translated to MP_LOG_BUFFER_MSGL_TERM, which is MSGL_MAX+1, because it's not an actual log level (blame C for not having proper sum types or something). Unfortunately, this unintentionally raised the internal log level to MSGL_MAX+1. It still functioned as intended, because log messages were simply filtered at a "later" point. But it led to every message being formatted even if not needed. More importantly, it made mp_msg_test() pointless (code calls this to avoid logging in "expensive" cases and if the messages would just get discarded). Also, this broke libplacebo logging, because the code to map the log messages did not expect a level higher than MSGL_MAX (mp_msg_level() returned MSGL_MAX+1 too). Fix this by not letting the dummy level value be used as log level. Messages at terminal log level will always make it to the inner log message dispatcher function (i.e. mp_msg_va() will call write_msg_to_buffers()), so log buffers which use the dummy log level don't need to adjust the actual log level at all.
-rw-r--r--common/msg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/msg.c b/common/msg.c
index 2756a27e8d..ca90bcaba5 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -123,8 +123,11 @@ static void update_loglevel(struct mp_log *log)
log->level = mp_msg_find_level(root->msg_levels[n * 2 + 1]);
}
log->terminal_level = log->level;
- for (int n = 0; n < log->root->num_buffers; n++)
- log->level = MPMAX(log->level, log->root->buffers[n]->level);
+ for (int n = 0; n < log->root->num_buffers; n++) {
+ int buffer_level = log->root->buffers[n]->level;
+ if (buffer_level != MP_LOG_BUFFER_MSGL_TERM)
+ log->level = MPMAX(log->level, buffer_level);
+ }
if (log->root->log_file)
log->level = MPMAX(log->level, MSGL_DEBUG);
if (log->root->stats_file)