1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 15:52:25 +00:00

lua: use core log level names

When the Lua code was written, the core didn't have names for log levels
yet (just numbers). The only user visible change is that "verbose"
becomes "v", since this level had different names.
This commit is contained in:
wm4 2014-01-16 21:37:29 +01:00
parent d646d78ccb
commit e10e1a57d0
2 changed files with 3 additions and 12 deletions

View File

@ -258,20 +258,11 @@ static void kill_script(struct script_ctx *ctx)
talloc_free(ctx); talloc_free(ctx);
} }
static const char *log_level[] = {
[MSGL_FATAL] = "fatal",
[MSGL_ERR] = "error",
[MSGL_WARN] = "warn",
[MSGL_INFO] = "info",
[MSGL_V] = "verbose",
[MSGL_DEBUG] = "debug",
};
static int check_loglevel(lua_State *L, int arg) static int check_loglevel(lua_State *L, int arg)
{ {
const char *level = luaL_checkstring(L, arg); const char *level = luaL_checkstring(L, arg);
for (int n = 0; n < MP_ARRAY_SIZE(log_level); n++) { for (int n = 0; n < MSGL_MAX; n++) {
if (log_level[n] && strcasecmp(log_level[n], level) == 0) if (mp_log_levels[n] && strcasecmp(mp_log_levels[n], level) == 0)
return n; return n;
} }
luaL_error(L, "Invalid log level '%s'", level); luaL_error(L, "Invalid log level '%s'", level);

View File

@ -70,7 +70,7 @@ mp.msg = {
error = function(...) return mp.log("error", ...) end, error = function(...) return mp.log("error", ...) end,
warn = function(...) return mp.log("warn", ...) end, warn = function(...) return mp.log("warn", ...) end,
info = function(...) return mp.log("info", ...) end, info = function(...) return mp.log("info", ...) end,
verbose = function(...) return mp.log("verbose", ...) end, verbose = function(...) return mp.log("v", ...) end,
debug = function(...) return mp.log("debug", ...) end, debug = function(...) return mp.log("debug", ...) end,
} }