msg: make --msg-level affect --log-file too

But --msg-level can only raise the log level used for --log-file,
because the original idea with --log-file was that it'd log verbose
messages to disk even if terminal logging is lower than -v or fully
disabled.
This commit is contained in:
wm4 2017-10-04 22:08:19 +02:00
parent bfae72a278
commit 10dd120baa
2 changed files with 6 additions and 3 deletions

View File

@ -403,8 +403,9 @@ Program Behavior
``--log-file=<path>``
Opens the given path for writing, and print log messages to it. Existing
files will be truncated. The log level always corresponds to ``-v``,
regardless of terminal verbosity levels.
files will be truncated. The log level is at least ``-v``, but can be
raised via ``--msg-level`` (the option cannot lower it below the forced
minimum log level).
``--config-dir=<path>``
Force a different configuration directory. If this is set, the given
@ -3380,6 +3381,8 @@ Terminal
can use the module names printed in the output (prefixed to each line in
``[...]``) to limit the output to interesting modules.
This also affects ``--log-file``, and in certain cases libmpv API logging.
.. note::
Some messages are printed before the command line is parsed and are

View File

@ -285,7 +285,7 @@ static void write_log_file(struct mp_log *log, int lev, char *text)
{
struct mp_log_root *root = log->root;
if (lev > MSGL_V || !root->log_file)
if (!root->log_file || lev > MPMAX(MSGL_V, log->terminal_level))
return;
fprintf(root->log_file, "[%8.3f][%c][%s] %s",