From dbc41ea3bbf48bc5d7dd625fb7930b4a3b498cf7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Nov 2014 15:36:30 +0100 Subject: ipc: make it possible to receive log messages The receiving part was implemented, but since no messages are enabled by default, it couldn't be used. --- DOCS/man/ipc.rst | 10 ++++++++++ input/ipc.c | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/DOCS/man/ipc.rst b/DOCS/man/ipc.rst index 2b5b3d2156..f1e466a497 100644 --- a/DOCS/man/ipc.rst +++ b/DOCS/man/ipc.rst @@ -146,6 +146,16 @@ extra commands can also be used as part of the protocol: { "command": ["unobserve_property", 1] } { "error": "success" } +``request_log_messages`` + Enable output of mpv log messages. They will be received as events. The + parameter to this command is the log-level (see ``mpv_request_log_messages`` + C API function). + + Log message output is meant for humans only (mostly for debugging). + Attempting to retrieve information by parsing these messages will just + lead to breakages with future mpv releases. Instead, make a feature request, + and ask for a proper event that returns the information you need. + ``suspend`` Suspend the mpv main loop. There is a long-winded explanation of this in the C API function ``mpv_suspend()``. In short, this prevents the player diff --git a/input/ipc.c b/input/ipc.c index 548bb3fe39..5d470ac257 100644 --- a/input/ipc.c +++ b/input/ipc.c @@ -414,6 +414,19 @@ static char *json_execute_command(struct client_arg *arg, void *ta_parent, rc = mpv_unobserve_property(arg->client, cmd_node->u.list->values[1].u.int64); + } else if (!strcmp("request_log_messages", cmd)) { + if (cmd_node->u.list->num != 2) { + rc = MPV_ERROR_INVALID_PARAMETER; + goto error; + } + + if (cmd_node->u.list->values[1].format != MPV_FORMAT_STRING) { + rc = MPV_ERROR_INVALID_PARAMETER; + goto error; + } + + rc = mpv_request_log_messages(arg->client, + cmd_node->u.list->values[1].u.string); } else if (!strcmp("suspend", cmd)) { if (arg->suspend_counter < INT_MAX) { mpv_suspend(arg->client); -- cgit v1.2.3