@@ -146,7 +146,7 @@ bool Session::Listen(Connection& conn)
146146 conn.sock = StreamAccept ();
147147 return true ;
148148 } catch (const std::runtime_error& e) {
149- Log ( " Error listening : %s" , e.what ());
149+ LogPrintLevel (BCLog::I2P, BCLog::Level:: Error, " Couldn't listen : %s\n " , e.what ());
150150 CheckControlSock ();
151151 }
152152 return false ;
@@ -202,7 +202,7 @@ bool Session::Accept(Connection& conn)
202202 return true ;
203203 }
204204
205- Log ( " Error accepting%s: %s" , disconnect ? " (will close the session)" : " " , errmsg);
205+ LogPrintLevel (BCLog::I2P, BCLog::Level::Debug, " Error accepting%s: %s\n " , disconnect ? " (will close the session)" : " " , errmsg);
206206 if (disconnect) {
207207 LOCK (m_mutex);
208208 Disconnect ();
@@ -217,7 +217,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
217217 // Refuse connecting to arbitrary ports. We don't specify any destination port to the SAM proxy
218218 // when connecting (SAM 3.1 does not use ports) and it forces/defaults it to I2P_SAM31_PORT.
219219 if (to.GetPort () != I2P_SAM31_PORT) {
220- Log ( " Error connecting to %s, connection refused due to arbitrary port %s" , to.ToStringAddrPort (), to.GetPort ());
220+ LogPrintLevel (BCLog::I2P, BCLog::Level::Debug, " Error connecting to %s, connection refused due to arbitrary port %s\n " , to.ToStringAddrPort (), to.GetPort ());
221221 proxy_error = false ;
222222 return false ;
223223 }
@@ -265,7 +265,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
265265
266266 throw std::runtime_error (strprintf (" \" %s\" " , connect_reply.full ));
267267 } catch (const std::runtime_error& e) {
268- Log ( " Error connecting to %s: %s" , to.ToStringAddrPort (), e.what ());
268+ LogPrintLevel (BCLog::I2P, BCLog::Level::Debug, " Error connecting to %s: %s\n " , to.ToStringAddrPort (), e.what ());
269269 CheckControlSock ();
270270 return false ;
271271 }
@@ -283,12 +283,6 @@ std::string Session::Reply::Get(const std::string& key) const
283283 return pos->second .value ();
284284}
285285
286- template <typename ... Args>
287- void Session::Log (const std::string& fmt, const Args&... args) const
288- {
289- LogPrint (BCLog::I2P, " %s\n " , tfm::format (fmt, args...));
290- }
291-
292286Session::Reply Session::SendRequestAndGetReply (const Sock& sock,
293287 const std::string& request,
294288 bool check_result_ok) const
@@ -344,7 +338,7 @@ void Session::CheckControlSock()
344338
345339 std::string errmsg;
346340 if (m_control_sock && !m_control_sock->IsConnected (errmsg)) {
347- Log ( " Control socket error: %s" , errmsg);
341+ LogPrintLevel (BCLog::I2P, BCLog::Level::Debug, " Control socket error: %s\n " , errmsg);
348342 Disconnect ();
349343 }
350344}
@@ -414,7 +408,7 @@ void Session::CreateIfNotCreatedAlready()
414408 const auto session_type = m_transient ? " transient" : " persistent" ;
415409 const auto session_id = GetRandHash ().GetHex ().substr (0 , 10 ); // full is overkill, too verbose in the logs
416410
417- Log ( " Creating %s SAM session %s with %s" , session_type, session_id, m_control_host.ToString ());
411+ LogPrintLevel (BCLog::I2P, BCLog::Level::Debug, " Creating %s SAM session %s with %s\n " , session_type, session_id, m_control_host.ToString ());
418412
419413 auto sock = Hello ();
420414
@@ -451,7 +445,7 @@ void Session::CreateIfNotCreatedAlready()
451445 m_session_id = session_id;
452446 m_control_sock = std::move (sock);
453447
454- Log ( " %s SAM session %s created, my address=%s" ,
448+ LogPrintLevel (BCLog::I2P, BCLog::Level::Info, " %s SAM session %s created, my address=%s\n " ,
455449 Capitalize (session_type),
456450 m_session_id,
457451 m_my_addr.ToStringAddrPort ());
@@ -482,9 +476,9 @@ void Session::Disconnect()
482476{
483477 if (m_control_sock) {
484478 if (m_session_id.empty ()) {
485- Log ( " Destroying incomplete SAM session" );
479+ LogPrintLevel (BCLog::I2P, BCLog::Level::Info, " Destroying incomplete SAM session\n " );
486480 } else {
487- Log ( " Destroying SAM session %s" , m_session_id);
481+ LogPrintLevel (BCLog::I2P, BCLog::Level::Info, " Destroying SAM session %s\n " , m_session_id);
488482 }
489483 m_control_sock.reset ();
490484 }
0 commit comments