Comparison

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
comparison
equal deleted inserted replaced
5448:cbe9fa2d3787 5449:35a271b4b920
202 LOG_CRIT, 202 LOG_CRIT,
203 -1 203 -1
204 }; 204 };
205 int lc_syslog_log(lua_State* L) 205 int lc_syslog_log(lua_State* L)
206 { 206 {
207 int level = luaL_checkoption(L, 1, "notice", level_strings); 207 int level = level_constants[luaL_checkoption(L, 1, "notice", level_strings)];
208 level = level_constants[level]; 208
209 209 if(lua_gettop(L) == 3)
210 luaL_checkstring(L, 2); 210 syslog(level, "%s: %s", luaL_checkstring(L, 2), luaL_checkstring(L, 3));
211 211 else
212 syslog(level, "%s", lua_tostring(L, 2)); 212 syslog(level, "%s", lua_tostring(L, 2));
213
213 return 0; 214 return 0;
214 } 215 }
215 216
216 int lc_syslog_close(lua_State* L) 217 int lc_syslog_close(lua_State* L)
217 { 218 {