summaryrefslogtreecommitdiff
path: root/src/l_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/l_log.c')
-rw-r--r--src/l_log.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/l_log.c b/src/l_log.c
index 7fb4e79..229624a 100644
--- a/src/l_log.c
+++ b/src/l_log.c
@@ -90,7 +90,7 @@ static int l_log_printf(lua_State *L)
return 0;
}
-static const struct luaL_reg log_funcs [] = {
+static const struct luaL_Reg log_funcs [] = {
{ "init", l_log_init },
{ "close", l_log_close },
{ "add_target", l_log_add_target },
@@ -101,7 +101,14 @@ static const struct luaL_reg log_funcs [] = {
LUALIB_API int luaopen_log(lua_State *L)
{
+#if LUA_VERSION_NUM > 501
+ lua_newtable(L);
+ luaL_setfuncs(L, log_funcs, 0);
+ lua_pushvalue(L, -1);
+ lua_setglobal(L, LUA_LOGLIBNAME);
+#else
luaL_register(L, LUA_LOGLIBNAME, log_funcs);
+#endif
lua_pushliteral(L, "ERROR");
lua_pushinteger(L, ERROR);
lua_settable(L, -3);