summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-08 14:15:14 +0200
committerwm4 <wm4@nowhere>2014-10-08 14:17:33 +0200
commit0ec5d35d57b57c68e93fc69f5fde9bbf3e19f50a (patch)
treefd2a88c64e19083b125ae88192d1c84b2591ad13 /common
parentab5d58c3d9ea908667b1d1715660911e878f20d6 (diff)
downloadmpv-0ec5d35d57b57c68e93fc69f5fde9bbf3e19f50a.tar.bz2
mpv-0ec5d35d57b57c68e93fc69f5fde9bbf3e19f50a.tar.xz
client API: introduce numeric log levels
Maybe using strings for log levels was a mistake (too broad and too impractical), so I'm adding numeric log level at least for the receiver side. This makes it easier to map mpv log levels to other logging systems. I'm still too stingy to add a function to set the log level by a numeric value, though. The numeric values are not directly mapped to the internal mpv values, because then almost every file in mpv would have to include the client API header. Coalesce this into API version 1.6, since 1.6 was bumped just yesterday.
Diffstat (limited to 'common')
-rw-r--r--common/msg.c14
-rw-r--r--common/msg_control.h1
2 files changed, 15 insertions, 0 deletions
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