mod_s2s: Remove tostring() in logging since this is handled by util.format now
authorKim Alvefur <zash@zash.se>
Thu, 21 Dec 2017 07:00:56 +0100
changeset 8486 6d47b74926dd
parent 8485 8b2219011386
child 8487 f591855f060d
mod_s2s: Remove tostring() in logging since this is handled by util.format now
plugins/mod_s2s/mod_s2s.lua
plugins/mod_s2s/s2sout.lib.lua
--- a/plugins/mod_s2s/mod_s2s.lua	Thu Dec 21 13:48:21 2017 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Thu Dec 21 07:00:56 2017 +0100
@@ -127,7 +127,7 @@
 			-- FIXME
 			if host.from_host ~= from_host then
 				log("error", "WARNING! This might, possibly, be a bug, but it might not...");
-				log("error", "We are going to send from %s instead of %s", tostring(host.from_host), tostring(from_host));
+				log("error", "We are going to send from %s instead of %s", host.from_host, from_host);
 			end
 			if host.sends2s(stanza) then
 				host.log("debug", "stanza sent over %s", host.type);
@@ -386,7 +386,7 @@
 			end
 
 			if ( session.type == "s2sin" or session.type == "s2sout" ) or features.tags[1] then
-				log("debug", "Sending stream features: %s", tostring(features));
+				log("debug", "Sending stream features: %s", features);
 				session.sends2s(features);
 			else
 				(session.log or log)("warn", "No stream features to offer, giving up");
@@ -443,7 +443,7 @@
 		session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}")));
 		session:close("invalid-namespace");
 	elseif error == "parse-error" then
-		session.log("debug", "Server-to-server XML parse error: %s", tostring(error));
+		session.log("debug", "Server-to-server XML parse error: %s", error);
 		session:close("not-well-formed");
 	elseif error == "stream-error" then
 		local condition, text = "undefined-condition";
@@ -490,10 +490,10 @@
 					if reason.extra then
 						stanza:add_child(reason.extra);
 					end
-					log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or session.ip or "(unknown host)", session.type, tostring(stanza));
+					log("debug", "Disconnecting %s[%s], <stream:error> is: %s", session.host or session.ip or "(unknown host)", session.type, stanza);
 					session.sends2s(stanza);
 				elseif reason.name then -- a stanza
-					log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s", session.from_host or "(unknown host)", session.to_host or "(unknown host)", session.type, tostring(reason));
+					log("debug", "Disconnecting %s->%s[%s], <stream:error> is: %s", session.from_host or "(unknown host)", session.to_host or "(unknown host)", session.type, reason);
 					session.sends2s(reason);
 				end
 			end
@@ -664,7 +664,7 @@
 				return; -- Session lives for now
 			end
 		end
-		(session.log or log)("debug", "s2s disconnected: %s->%s (%s)", tostring(session.from_host), tostring(session.to_host), tostring(err or "connection closed"));
+		(session.log or log)("debug", "s2s disconnected: %s->%s (%s)", session.from_host, session.to_host, err or "connection closed");
 		s2s_destroy_session(session, err);
 	end
 end
--- a/plugins/mod_s2s/s2sout.lib.lua	Thu Dec 21 13:48:21 2017 +0100
+++ b/plugins/mod_s2s/s2sout.lib.lua	Thu Dec 21 07:00:56 2017 +0100
@@ -68,9 +68,9 @@
 				buffer = {};
 				host_session.send_buffer = buffer;
 			end
-			log("debug", "Buffering data on unconnected s2sout to %s", tostring(host_session.to_host));
+			log("debug", "Buffering data on unconnected s2sout to %s", host_session.to_host);
 			buffer[#buffer+1] = data;
-			log("debug", "Buffered item %d: %s", #buffer, tostring(data));
+			log("debug", "Buffered item %d: %s", #buffer, data);
 		end
 	end
 end
@@ -129,16 +129,16 @@
 		host_session.srv_choice = host_session.srv_choice + 1;
 		local srv_choice = host_session.srv_hosts[host_session.srv_choice];
 		connect_host, connect_port = srv_choice.target or to_host, srv_choice.port or connect_port;
-		host_session.log("info", "Connection failed (%s). Attempt #%d: This time to %s:%d", tostring(err), host_session.srv_choice, connect_host, connect_port);
+		host_session.log("info", "Connection failed (%s). Attempt #%d: This time to %s:%d", err, host_session.srv_choice, connect_host, connect_port);
 	else
-		host_session.log("info", "Failed in all attempts to connect to %s", tostring(host_session.to_host));
+		host_session.log("info", "Failed in all attempts to connect to %s", host_session.to_host);
 		-- We're out of options
 		return false;
 	end
 
 	if not (connect_host and connect_port) then
 		-- Likely we couldn't resolve DNS
-		log("warn", "Hmm, we're without a host (%s) and port (%s) to connect to for %s, giving up :(", tostring(connect_host), tostring(connect_port), tostring(to_host));
+		log("warn", "Hmm, we're without a host (%s) and port (%s) to connect to for %s, giving up :(", connect_host, connect_port, to_host);
 		return false;
 	end