@@ -146,7 +146,7 @@ bool Session::Listen(Connection& conn)
146
146
conn.sock = StreamAccept ();
147
147
return true ;
148
148
} 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 ());
150
150
CheckControlSock ();
151
151
}
152
152
return false ;
@@ -202,7 +202,7 @@ bool Session::Accept(Connection& conn)
202
202
return true ;
203
203
}
204
204
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);
206
206
if (disconnect) {
207
207
LOCK (m_mutex);
208
208
Disconnect ();
@@ -217,7 +217,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
217
217
// Refuse connecting to arbitrary ports. We don't specify any destination port to the SAM proxy
218
218
// when connecting (SAM 3.1 does not use ports) and it forces/defaults it to I2P_SAM31_PORT.
219
219
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 ());
221
221
proxy_error = false ;
222
222
return false ;
223
223
}
@@ -265,7 +265,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error)
265
265
266
266
throw std::runtime_error (strprintf (" \" %s\" " , connect_reply.full ));
267
267
} 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 ());
269
269
CheckControlSock ();
270
270
return false ;
271
271
}
@@ -283,12 +283,6 @@ std::string Session::Reply::Get(const std::string& key) const
283
283
return pos->second .value ();
284
284
}
285
285
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
-
292
286
Session::Reply Session::SendRequestAndGetReply (const Sock& sock,
293
287
const std::string& request,
294
288
bool check_result_ok) const
@@ -344,7 +338,7 @@ void Session::CheckControlSock()
344
338
345
339
std::string errmsg;
346
340
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);
348
342
Disconnect ();
349
343
}
350
344
}
@@ -414,7 +408,7 @@ void Session::CreateIfNotCreatedAlready()
414
408
const auto session_type = m_transient ? " transient" : " persistent" ;
415
409
const auto session_id = GetRandHash ().GetHex ().substr (0 , 10 ); // full is overkill, too verbose in the logs
416
410
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 ());
418
412
419
413
auto sock = Hello ();
420
414
@@ -451,7 +445,7 @@ void Session::CreateIfNotCreatedAlready()
451
445
m_session_id = session_id;
452
446
m_control_sock = std::move (sock);
453
447
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 " ,
455
449
Capitalize (session_type),
456
450
m_session_id,
457
451
m_my_addr.ToStringAddrPort ());
@@ -482,9 +476,9 @@ void Session::Disconnect()
482
476
{
483
477
if (m_control_sock) {
484
478
if (m_session_id.empty ()) {
485
- Log ( " Destroying incomplete SAM session" );
479
+ LogPrintLevel (BCLog::I2P, BCLog::Level::Info, " Destroying incomplete SAM session\n " );
486
480
} 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);
488
482
}
489
483
m_control_sock.reset ();
490
484
}
0 commit comments