From 8c5ea38cda7a424d89e080fd16d8902dd7b1d29e Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 16 Jan 2014 21:34:47 +0100 Subject: msg: expose log level names --- common/msg.c | 6 +++--- common/msg.h | 2 ++ common/msg_control.h | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/common/msg.c b/common/msg.c index 81a966c880..4ef269a963 100644 --- a/common/msg.c +++ b/common/msg.c @@ -477,7 +477,7 @@ void mp_msg(struct mp_log *log, int lev, const char *format, ...) va_end(va); } -static const char *level_names[] = { +char *mp_log_levels[MSGL_MAX + 1] = { [MSGL_FATAL] = "fatal", [MSGL_ERR] = "error", [MSGL_WARN] = "warn", @@ -498,8 +498,8 @@ int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level) if (!bstr_split_tok(elem, "=", &mod, &level) || mod.len == 0) return -1; int ilevel = -1; - for (int n = 0; n < MP_ARRAY_SIZE(level_names); n++) { - if (level_names[n] && bstr_equals0(level, level_names[n])) { + for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) { + if (mp_log_levels[n] && bstr_equals0(level, mp_log_levels[n])) { ilevel = n; break; } diff --git a/common/msg.h b/common/msg.h index 386151a768..d56ce13976 100644 --- a/common/msg.h +++ b/common/msg.h @@ -42,6 +42,8 @@ enum { MSGL_DEBUG, // -v -v MSGL_TRACE, // -v -v -v MSGL_SMODE, // old slave mode (-identify) + + MSGL_MAX = MSGL_SMODE, }; struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, diff --git a/common/msg_control.h b/common/msg_control.h index 65b64eff5e..ecce7ca0eb 100644 --- a/common/msg_control.h +++ b/common/msg_control.h @@ -27,4 +27,6 @@ struct mp_log_buffer_entry *mp_msg_log_buffer_read(struct mp_log_buffer *buffer) struct bstr; int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level); +extern char *mp_log_levels[MSGL_MAX + 1]; + #endif -- cgit v1.2.3