Merge pull request #36 from tiosgz/verbosity

Add controls for verbosity level
This commit is contained in:
buffet 2021-08-13 17:43:20 +00:00 committed by GitHub
commit bad27b27aa
2 changed files with 41 additions and 0 deletions

View file

@ -191,6 +191,25 @@ l_kiwmi_server_schedule(lua_State *L)
return 0; return 0;
} }
static int
l_kiwmi_server_set_verbosity(lua_State *L)
{
luaL_checkudata(L, 1, "kiwmi_server");
luaL_checktype(L, 2, LUA_TNUMBER);
int verbosity = lua_tointeger(L, 2);
if (verbosity < WLR_SILENT) {
verbosity = WLR_SILENT;
} else if (verbosity >= WLR_LOG_IMPORTANCE_LAST) {
verbosity = WLR_DEBUG;
}
wlr_log_init((enum wlr_log_importance)verbosity, NULL);
return 0;
}
static int static int
l_kiwmi_server_spawn(lua_State *L) l_kiwmi_server_spawn(lua_State *L)
{ {
@ -241,6 +260,18 @@ l_kiwmi_server_unfocus(lua_State *L)
return 0; return 0;
} }
static int
l_kiwmi_server_verbosity(lua_State *L)
{
luaL_checkudata(L, 1, "kiwmi_server");
int verbosity = (int)wlr_log_get_verbosity();
lua_pushinteger(L, verbosity);
return 1;
}
static int static int
l_kiwmi_server_view_at(lua_State *L) l_kiwmi_server_view_at(lua_State *L)
{ {
@ -284,9 +315,11 @@ static const luaL_Reg kiwmi_server_methods[] = {
{"output_at", l_kiwmi_server_output_at}, {"output_at", l_kiwmi_server_output_at},
{"quit", l_kiwmi_server_quit}, {"quit", l_kiwmi_server_quit},
{"schedule", l_kiwmi_server_schedule}, {"schedule", l_kiwmi_server_schedule},
{"set_verbosity", l_kiwmi_server_set_verbosity},
{"spawn", l_kiwmi_server_spawn}, {"spawn", l_kiwmi_server_spawn},
{"stop_interactive", l_kiwmi_server_stop_interactive}, {"stop_interactive", l_kiwmi_server_stop_interactive},
{"unfocus", l_kiwmi_server_unfocus}, {"unfocus", l_kiwmi_server_unfocus},
{"verbosity", l_kiwmi_server_verbosity},
{"view_at", l_kiwmi_server_view_at}, {"view_at", l_kiwmi_server_view_at},
{NULL, NULL}, {NULL, NULL},
}; };

View file

@ -50,6 +50,10 @@ Quit kiwmi.
Call `callback` after `delay` ms. Call `callback` after `delay` ms.
Callback get passed itself, so that it can easily reregister itself. Callback get passed itself, so that it can easily reregister itself.
#### kiwmi:set_verbosity(level)
Sets verbosity of kiwmi to the level specified with a number (see `kiwmi:verbosity()`).
#### kiwmi:spawn(command) #### kiwmi:spawn(command)
Spawn a new process. Spawn a new process.
@ -63,6 +67,10 @@ Stops an interactive move or resize.
Unfocus the currently focused view. Unfocus the currently focused view.
#### kiwmi:verbosity()
Returns the numerical verbosity level of kiwmi (value of one of `wlr_log_importance`, silent = 0, error = 1, info = 2, debug = 3).
#### kiwmi:view_at(lx, ly) #### kiwmi:view_at(lx, ly)
Get the view at a specified position. Get the view at a specified position.