1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Lua shutdown hook and logging api

This commit is contained in:
James Booth 2013-09-15 16:13:56 +01:00
parent c4fcfb77cc
commit 32f39ef6fd
2 changed files with 12 additions and 28 deletions

View File

@ -142,55 +142,32 @@ lua_api_get_current_recipient(lua_State *L)
static int static int
lua_api_log_debug(lua_State *L) lua_api_log_debug(lua_State *L)
{ {
/* const char *message = lua_tostring(L, 1);
const char *message = NULL;
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
api_log_debug(message); api_log_debug(message);
return Py_BuildValue("");
*/
return 0; return 0;
} }
static int static int
lua_api_log_info(lua_State *L) lua_api_log_info(lua_State *L)
{ {
/* const char *message = lua_tostring(L, 1);
const char *message = NULL;
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
api_log_info(message); api_log_info(message);
return Py_BuildValue(""); return 0;
*/
} }
static int static int
lua_api_log_warning(lua_State *L) lua_api_log_warning(lua_State *L)
{ {
/* const char *message = lua_tostring(L, 1);
const char *message = NULL;
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
api_log_warning(message); api_log_warning(message);
return Py_BuildValue("");
*/
return 0; return 0;
} }
static int static int
lua_api_log_error(lua_State *L) lua_api_log_error(lua_State *L)
{ {
/* const char *message = lua_tostring(L, 1);
const char *message = NULL;
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
api_log_error(message); api_log_error(message);
return Py_BuildValue("");
*/
return 0; return 0;
} }

View File

@ -294,6 +294,13 @@ lua_on_room_message_send_hook(ProfPlugin *plugin, const char * const room,
void void
lua_on_shutdown_hook(ProfPlugin *plugin) lua_on_shutdown_hook(ProfPlugin *plugin)
{ {
int *p_ref = (int *)plugin->module;
lua_rawgeti(L, LUA_REGISTRYINDEX, *p_ref);
lua_pushstring(L, "prof_on_shutdown");
lua_gettable(L, -2);
int res2 = lua_pcall(L, 0, 0, 0);
lua_check_error(res2);
lua_pop(L, 1);
} }
void void