summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/client-api-changes.rst1
-rw-r--r--common/msg.c14
-rw-r--r--common/msg_control.h1
-rw-r--r--libmpv/client.h25
-rw-r--r--player/client.c1
5 files changed, 41 insertions, 1 deletions
diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst
index 851f3e917c..8943855f13 100644
--- a/DOCS/client-api-changes.rst
+++ b/DOCS/client-api-changes.rst
@@ -27,6 +27,7 @@ API changes
1.6 - modify "core-idle" property behavior
- MPV_EVENT_LOG_MESSAGE now always sends complete lines
+ - introduce numeric log levels (mpv_log_level)
--- mpv 0.6.0 is released ---
1.5 - change in X11 and "--wid" behavior again. The previous change didn't
work as expected, and now the behavior can be explicitly controlled
diff --git a/common/msg.c b/common/msg.c
index f59c7bdc88..9ca7da9479 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -37,6 +37,8 @@
#include "osdep/io.h"
#include "osdep/timer.h"
+#include "libmpv/client.h"
+
#include "msg.h"
#include "msg_control.h"
@@ -600,6 +602,18 @@ const char *const mp_log_levels[MSGL_MAX + 1] = {
[MSGL_STATS] = "stats",
};
+const int const mp_mpv_log_levels[MSGL_MAX + 1] = {
+ [MSGL_FATAL] = MPV_LOG_LEVEL_FATAL,
+ [MSGL_ERR] = MPV_LOG_LEVEL_ERROR,
+ [MSGL_WARN] = MPV_LOG_LEVEL_WARN,
+ [MSGL_INFO] = MPV_LOG_LEVEL_INFO,
+ [MSGL_STATUS] = 0, // never used
+ [MSGL_V] = MPV_LOG_LEVEL_V,
+ [MSGL_DEBUG] = MPV_LOG_LEVEL_DEBUG,
+ [MSGL_TRACE] = MPV_LOG_LEVEL_TRACE,
+ [MSGL_STATS] = 0, // never used
+};
+
int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level)
{
if (s->len == 0)
diff --git a/common/msg_control.h b/common/msg_control.h
index f659d180b2..cd2cefa249 100644
--- a/common/msg_control.h
+++ b/common/msg_control.h
@@ -32,5 +32,6 @@ struct bstr;
int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level);
extern const char *const mp_log_levels[MSGL_MAX + 1];
+extern const int const mp_mpv_log_levels[MSGL_MAX + 1];
#endif
diff --git a/libmpv/client.h b/libmpv/client.h
index 98164ce813..9b2d67edd2 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -1030,6 +1030,23 @@ typedef struct mpv_event_property {
void *data;
} mpv_event_property;
+/**
+ * Numeric log levels. The lower the number, the more important the message is.
+ * MPV_LOG_LEVEL_NONE is never used when receiving messages. The string in
+ * the comment after the value is the name of the log level as used for the
+ * mpv_request_log_messages() function.
+ */
+typedef enum mpv_log_level {
+ MPV_LOG_LEVEL_NONE = 0, /// "no" - disable absolutely all messages
+ MPV_LOG_LEVEL_FATAL = 10, /// "fatal" - critical/aborting errors
+ MPV_LOG_LEVEL_ERROR = 20, /// "error" - simple errors
+ MPV_LOG_LEVEL_WARN = 30, /// "warn" - possible problems
+ MPV_LOG_LEVEL_INFO = 40, /// "info" - informational message
+ MPV_LOG_LEVEL_V = 50, /// "v" - noisy informational message
+ MPV_LOG_LEVEL_DEBUG = 60, /// "debug" - very noisy technical information
+ MPV_LOG_LEVEL_TRACE = 70, /// "trace" - extremely noisy
+} mpv_log_level;
+
typedef struct mpv_event_log_message {
/**
* The module prefix, identifies the sender of the message. As a special
@@ -1040,7 +1057,7 @@ typedef struct mpv_event_log_message {
const char *prefix;
/**
* The log level as string. See mpv_request_log_messages() for possible
- * values.
+ * values. The level "no" is never used here.
*/
const char *level;
/**
@@ -1049,6 +1066,11 @@ typedef struct mpv_event_log_message {
* or partial lines.)
*/
const char *text;
+ /**
+ * The same contents as the level field, but as a numeric ID.
+ * Since API version 1.6.
+ */
+ mpv_log_level log_level;
} mpv_event_log_message;
typedef struct mpv_event_end_file {
@@ -1146,6 +1168,7 @@ int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable);
* @param min_level Minimal log level as string. Valid log levels:
* no fatal error warn info status v debug trace
* The value "no" disables all messages. This is the default.
+ * Also see mpv_log_level.
*/
int mpv_request_log_messages(mpv_handle *ctx, const char *min_level);
diff --git a/player/client.c b/player/client.c
index a7700fbd1c..f64f0bd976 100644
--- a/player/client.c
+++ b/player/client.c
@@ -654,6 +654,7 @@ mpv_event *mpv_wait_event(mpv_handle *ctx, double timeout)
*cmsg = (struct mpv_event_log_message){
.prefix = talloc_steal(event, msg->prefix),
.level = mp_log_levels[msg->level],
+ .log_level = mp_mpv_log_levels[msg->level],
.text = talloc_steal(event, msg->text),
};
event->data = cmsg;