Skip to content

Commit

Permalink
msg: add msg-status-stderr option
Browse files Browse the repository at this point in the history
Fixes: #14133
  • Loading branch information
kasper93 committed May 13, 2024
1 parent 696c626 commit fd62230
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/msg-status-stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add `--msg-status-stderr` option
3 changes: 3 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5000,6 +5000,9 @@ Terminal
later actually), using a monotonic time source depending on the OS. This
is ``CLOCK_MONOTONIC`` on sane UNIX variants.

``--msg-status-stderr``
Print status line to stderr.

Cache
-----

Expand Down
8 changes: 8 additions & 0 deletions common/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct mp_log_root {
// --- protected by log_file_lock
bool log_file_thread_active; // also termination signal for the thread
int module_indent;
bool status_stderr;
};

struct mp_log {
Expand Down Expand Up @@ -194,6 +195,8 @@ int mp_msg_level(struct mp_log *log)

static inline int term_msg_fileno(struct mp_log_root *root, int lev)
{
if (lev == MSGL_STATUS && root->status_stderr)
return STDERR_FILENO;
return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
}

Expand Down Expand Up @@ -770,6 +773,11 @@ void mp_msg_update_msglevels(struct mpv_global *global, struct MPOpts *opts)
root->use_terminal = opts->use_terminal;
root->show_time = opts->msg_time;

if (root->status_stderr != opts->msg_status_stderr) {
msg_flush_status_line(root, true);
root->status_stderr = opts->msg_status_stderr;
}

if (root->really_quiet)
root->status_lines = 0;

Expand Down
1 change: 1 addition & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ static const m_option_t mp_opts[] = {
.flags = CONF_PRE_PARSE | M_OPT_FILE | UPDATE_TERM},
{"msg-module", OPT_BOOL(msg_module), .flags = UPDATE_TERM},
{"msg-time", OPT_BOOL(msg_time), .flags = UPDATE_TERM},
{"msg-status-stderr", OPT_BOOL(msg_status_stderr), .flags = UPDATE_TERM},
#if HAVE_WIN32_DESKTOP
{"priority", OPT_CHOICE(w32_priority,
{"no", 0},
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ typedef struct MPOpts {
bool msg_color;
bool msg_module;
bool msg_time;
bool msg_status_stderr;
char *log_file;

int operation_mode;
Expand Down

0 comments on commit fd62230

Please sign in to comment.