1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-27 09:58:21 +01:00

allow lua to log to syslog

This commit is contained in:
DanyLE 2022-08-23 01:18:05 +02:00
parent 6276b0aa1e
commit 4259ec7eef
2 changed files with 9 additions and 0 deletions

View File

@ -102,6 +102,7 @@ void* lua_handle(void* data, void* meta)
__t(client, "Cannot run router: %s", lua_tostring(L, -1)); __t(client, "Cannot run router: %s", lua_tostring(L, -1));
} }
free(index);*/ free(index);*/
LOG("LUA handle exit on %d", rq->client->sock);
// clear request // clear request
if(L) if(L)
lua_close(L); lua_close(L);

View File

@ -182,6 +182,13 @@ static int l_setgid(lua_State* L)
lua_pushboolean(L,0); lua_pushboolean(L,0);
return 1; return 1;
} }
static int l_syslog(lua_State* L)
{
const int prio = luaL_checknumber(L,1);
const char* msg = luaL_checkstring(L,2);
syslog(prio, "%s", msg);
return 1;
}
static int l_getuid(lua_State* L) static int l_getuid(lua_State* L)
{ {
const char* name = luaL_checkstring(L,1); const char* name = luaL_checkstring(L,1);
@ -769,6 +776,7 @@ static const struct luaL_Reg _lib [] = {
{"unsetenv",l_unsetenv}, {"unsetenv",l_unsetenv},
{"home_dir",l_gethomedir}, {"home_dir",l_gethomedir},
{"send_file", l_send_file}, {"send_file", l_send_file},
{"syslog", l_syslog},
{NULL,NULL} {NULL,NULL}
}; };