Software /
code /
prosody
Diff
util-src/pposix.c @ 5449:35a271b4b920
util.pposix: syslog(): Support an optional source parameter (producing messages of the form '<source>: <message>'
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 08 Apr 2013 16:56:40 +0100 |
parent | 5359:43517e649c53 |
child | 5451:941ad88db8f3 |
line wrap: on
line diff
--- a/util-src/pposix.c Mon Apr 08 16:40:27 2013 +0100 +++ b/util-src/pposix.c Mon Apr 08 16:56:40 2013 +0100 @@ -204,12 +204,13 @@ }; int lc_syslog_log(lua_State* L) { - int level = luaL_checkoption(L, 1, "notice", level_strings); - level = level_constants[level]; + int level = level_constants[luaL_checkoption(L, 1, "notice", level_strings)]; - luaL_checkstring(L, 2); + if(lua_gettop(L) == 3) + syslog(level, "%s: %s", luaL_checkstring(L, 2), luaL_checkstring(L, 3)); + else + syslog(level, "%s", lua_tostring(L, 2)); - syslog(level, "%s", lua_tostring(L, 2)); return 0; }