Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msg: add msg-status-stderr option #14139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading