mirror of
https://github.com/mpv-player/mpv
synced 2025-02-01 20:52:05 +00:00
msg: expose log level names
This commit is contained in:
parent
738dfbb2fe
commit
8c5ea38cda
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user