diff options
author | Christian Pointner <equinox@anylike.org> | 2009-12-25 10:07:47 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anylike.org> | 2009-12-25 10:07:47 +0000 |
commit | 3b0a3d401a4bff28c813c08b7362b025af5064c1 (patch) | |
tree | 0f736046c9599fc7d0aac3fe0ef82b65be6b42cc | |
parent | added lua_error (diff) |
added log.add_target to log library
-rw-r--r-- | src/l_log.c | 28 | ||||
-rw-r--r-- | src/main_loop.lua | 1 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/l_log.c b/src/l_log.c index d3319cb..e61c66c 100644 --- a/src/l_log.c +++ b/src/l_log.c @@ -30,11 +30,6 @@ #include "l_log.h" - -/* void log_init(); */ -/* void log_close(); */ -/* void update_max_prio(); */ -/* int log_add_target(const char* conf); */ /* void log_printf(log_prio_t prio, const char* fmt, ...); */ /* void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len); */ @@ -79,11 +74,30 @@ static int l_log_print(lua_State *L) return 0; } +static int l_log_add_target(lua_State *L) +{ + int ret = log_add_target(luaL_checklstring(L,1,NULL)); + if(ret) { + lua_pushboolean(L, 0); + switch(ret) { + case -2: lua_pushstring(L, "memory error at log_add_target"); break; + case -3: lua_pushstring(L, "unknown log target"); break; + case -4: lua_pushstring(L, "this log target is only allowed once"); break; + default: lua_pushstring(L, "syntax error"); break; + } + return 2; + } + + lua_pushboolean(L, 1); + return 1; +} + static const struct luaL_reg loglib [] = { { "init", l_log_init }, { "close", l_log_close }, - { "print", l_log_print }, - { NULL, NULL } + { "print", l_log_print }, + { "add_target", l_log_add_target }, + { NULL, NULL } }; diff --git a/src/main_loop.lua b/src/main_loop.lua index 746570e..9e9e0ae 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -29,3 +29,4 @@ log.print("DEBUG", "yet anoter message"); log.print("ERROR", "this is an error"); + |