# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1528992983 -7200
# Node ID cea6165a03d04a67d9384be01b44bc833ace3f93
# Parent  28ec1e024379e430320698c0715e91f535709d8d
mod_s2s: Use session logger to ease debugging

diff -r 28ec1e024379 -r cea6165a03d0 plugins/mod_s2s/s2sout.lib.lua
--- a/plugins/mod_s2s/s2sout.lib.lua	Thu Jun 14 16:13:56 2018 +0200
+++ b/plugins/mod_s2s/s2sout.lib.lua	Thu Jun 14 18:16:23 2018 +0200
@@ -46,6 +46,8 @@
 end
 
 function s2sout.initiate_connection(host_session)
+	local log = host_session.log or log;
+
 	initialize_filters(host_session);
 	host_session.version = 1;
 
@@ -84,6 +86,7 @@
 function s2sout.attempt_connection(host_session, err)
 	local to_host = host_session.to_host;
 	local connect_host, connect_port = to_host and idna_to_ascii(to_host), 5269;
+	local log = host_session.log or log;
 
 	if not connect_host then
 		return false;
@@ -166,6 +169,7 @@
 
 function s2sout.try_connect(host_session, connect_host, connect_port, err)
 	host_session.connecting = true;
+	local log = host_session.log or log;
 
 	if not err then
 		local IPs = {};
@@ -266,7 +270,8 @@
 end
 
 function s2sout.make_connect(host_session, connect_host, connect_port)
-	(host_session.log or log)("debug", "Beginning new connection attempt to %s ([%s]:%d)", host_session.to_host, connect_host.addr, connect_port);
+	local log = host_session.log or log;
+	log("debug", "Beginning new connection attempt to %s ([%s]:%d)", host_session.to_host, connect_host.addr, connect_port);
 
 	-- Reset secure flag in case this is another
 	-- connection attempt after a failed STARTTLS