From 4259ec7eef754cae78054d42aa6c7844321edb02 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Tue, 23 Aug 2022 01:18:05 +0200 Subject: [PATCH] allow lua to log to syslog --- lib/asl/handle.c | 1 + lib/asl/ulib.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/asl/handle.c b/lib/asl/handle.c index 6a88c6a..5f660bf 100644 --- a/lib/asl/handle.c +++ b/lib/asl/handle.c @@ -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); diff --git a/lib/asl/ulib.c b/lib/asl/ulib.c index d93ca6c..be339eb 100644 --- a/lib/asl/ulib.c +++ b/lib/asl/ulib.c @@ -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} };