prosody: Modified function metatable for better string representation of functions.
authorWaqas Hussain <waqas20@gmail.com>
Fri, 07 May 2010 16:02:29 +0500
changeset 3024 9c74785c6351
parent 3023 454e1cf18daf
child 3025 f1e1b7629807
prosody: Modified function metatable for better string representation of functions.
prosody
--- a/prosody	Fri May 07 16:00:33 2010 +0500
+++ b/prosody	Fri May 07 16:02:29 2010 +0500
@@ -143,6 +143,10 @@
 			debug.setupvalue(f, i, value);
 		end
 	end
+	function mt.__tostring(f)
+		local info = debug.getinfo(f);
+		return ("function(%s:%d)"):format(info.short_src:match("[^\\/]*$"), info.linedefined);
+	end
 	debug.setmetatable(function() end, mt);
 end