1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-26 17:38: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));
}
free(index);*/
LOG("LUA handle exit on %d", rq->client->sock);
// clear request
if(L)
lua_close(L);

View File

@ -182,6 +182,13 @@ static int l_setgid(lua_State* L)
lua_pushboolean(L,0);
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)
{
const char* name = luaL_checkstring(L,1);
@ -769,6 +776,7 @@ static const struct luaL_Reg _lib [] = {
{"unsetenv",l_unsetenv},
{"home_dir",l_gethomedir},
{"send_file", l_send_file},
{"syslog", l_syslog},
{NULL,NULL}
};