util.pposix: syslog(): Support an optional source parameter (producing messages of the form '<source>: <message>'
authorMatthew Wild <mwild1@gmail.com>
Mon, 08 Apr 2013 16:56:40 +0100
changeset 5449 35a271b4b920
parent 5448 cbe9fa2d3787
child 5450 cc83b1a50fde
util.pposix: syslog(): Support an optional source parameter (producing messages of the form '<source>: <message>'
util-src/pposix.c
--- 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;
 }