mirror of
https://github.com/mpv-player/mpv
synced 2025-02-19 22:36:55 +00:00
player: make sure version information is always included in --log-file
If --log-file was used in config files, this could be missing due to the exact timing when the messages are print, and when the options are applied. Fix this by always dumping the version again when a log file is opened.
This commit is contained in:
parent
5974f575a6
commit
25a4d10c8e
13
common/msg.c
13
common/msg.c
@ -537,7 +537,20 @@ void mp_msg_force_stderr(struct mpv_global *global, bool force_stderr)
|
||||
{
|
||||
struct mp_log_root *root = global->log->root;
|
||||
|
||||
pthread_mutex_lock(&mp_msg_lock);
|
||||
root->force_stderr = force_stderr;
|
||||
pthread_mutex_unlock(&mp_msg_lock);
|
||||
}
|
||||
|
||||
bool mp_msg_has_log_file(struct mpv_global *global)
|
||||
{
|
||||
struct mp_log_root *root = global->log->root;
|
||||
|
||||
pthread_mutex_lock(&mp_msg_lock);
|
||||
bool res = !!root->log_file;
|
||||
pthread_mutex_unlock(&mp_msg_lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void mp_msg_uninit(struct mpv_global *global)
|
||||
|
@ -9,6 +9,7 @@ void mp_msg_uninit(struct mpv_global *global);
|
||||
void mp_msg_update_msglevels(struct mpv_global *global);
|
||||
void mp_msg_force_stderr(struct mpv_global *global, bool force_stderr);
|
||||
bool mp_msg_has_status_line(struct mpv_global *global);
|
||||
bool mp_msg_has_log_file(struct mpv_global *global);
|
||||
|
||||
void mp_msg_flush_status_line(struct mp_log *log);
|
||||
|
||||
|
@ -114,6 +114,8 @@ static bool cas_terminal_owner(struct MPContext *old, struct MPContext *new)
|
||||
|
||||
void mp_update_logging(struct MPContext *mpctx, bool preinit)
|
||||
{
|
||||
bool had_log_file = mp_msg_has_log_file(mpctx->global);
|
||||
|
||||
mp_msg_update_msglevels(mpctx->global);
|
||||
|
||||
bool enable = mpctx->opts->use_terminal;
|
||||
@ -128,6 +130,9 @@ void mp_update_logging(struct MPContext *mpctx, bool preinit)
|
||||
}
|
||||
}
|
||||
|
||||
if (mp_msg_has_log_file(mpctx->global) && !had_log_file)
|
||||
mp_print_version(mpctx->log, false); // for log-file=... in config files
|
||||
|
||||
if (enabled && !preinit && mpctx->opts->consolecontrols)
|
||||
terminal_setup_getch(mpctx->input);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user