0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-19 00:10:59 +01:00

ircd::net: Update log messages.

This commit is contained in:
Jason Volk 2017-10-25 10:02:45 -07:00
parent 8b573378e8
commit 888c7d5739

View file

@ -689,9 +689,9 @@ noexcept try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p) ~scope_timeout: %s", log.error("socket(%p) ~scope_timeout: %s",
(const void *)s, (const void *)s,
e.what()); e.what());
return; return;
} }
@ -709,9 +709,9 @@ noexcept try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p) scope_timeout::cancel: %s", log.error("socket(%p) scope_timeout::cancel: %s",
(const void *)s, (const void *)s,
e.what()); e.what());
return false; return false;
} }
@ -753,27 +753,9 @@ ircd::net::socket::socket(const ip::tcp::endpoint &remote,
const milliseconds &timeout, const milliseconds &timeout,
asio::ssl::context &ssl, asio::ssl::context &ssl,
boost::asio::io_service *const &ios) boost::asio::io_service *const &ios)
try
:socket{ssl, ios} :socket{ssl, ios}
{ {
log::debug("socket(%p) attempting connect to remote: %s for the next %ld$ms",
this,
string(remote),
timeout.count());
connect(remote, timeout); connect(remote, timeout);
log::debug("socket(%p) connected to remote: %s from local: %s",
this,
string(remote),
string(local()));
}
catch(const std::exception &e)
{
log::debug("socket(%p) failed to connect to remote %s: %s",
this,
string(remote),
e.what());
} }
ircd::net::socket::socket(asio::ssl::context &ssl, ircd::net::socket::socket(asio::ssl::context &ssl,
@ -804,7 +786,7 @@ noexcept try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p): close: %s", this, e.what()); log.error("socket(%p): close: %s", this, e.what());
return; return;
} }
@ -813,11 +795,33 @@ catch(const std::exception &e)
void void
ircd::net::socket::connect(const ip::tcp::endpoint &ep, ircd::net::socket::connect(const ip::tcp::endpoint &ep,
const milliseconds &timeout) const milliseconds &timeout)
try
{ {
const scope_timeout ts{*this, timeout}; log.debug("socket(%p) attempting connect to remote: %s for the next %ld$ms",
this,
string(ep),
timeout.count());
ip::tcp::socket &sd(*this); ip::tcp::socket &sd(*this);
const scope_timeout ts{*this, timeout};
sd.async_connect(ep, yield_context{to_asio{}}); sd.async_connect(ep, yield_context{to_asio{}});
log.debug("socket(%p) connected to remote: %s from local: %s; performing handshake...",
this,
string(ep),
string(local()));
ssl.async_handshake(socket::handshake_type::client, yield_context{to_asio{}}); ssl.async_handshake(socket::handshake_type::client, yield_context{to_asio{}});
log.debug("socket(%p) secure session with %s from local: %s established.",
this,
string(ep),
string(local()));
}
catch(const std::exception &e)
{
log.debug("socket(%p) failed to connect to remote %s: %s",
this,
string(ep),
e.what());
} }
/// Attempt to connect and ssl handshake remote; yields ircd::ctx; throws timeout /// Attempt to connect and ssl handshake remote; yields ircd::ctx; throws timeout
@ -887,10 +891,10 @@ try
timer.cancel(); timer.cancel();
if(sd.is_open()) if(sd.is_open())
log::debug("socket(%p): disconnect: %s type: %d", log.debug("socket(%p): disconnect: %s type: %d",
(const void *)this, (const void *)this,
string(remote()), string(remote()),
uint(type)); uint(type));
if(sd.is_open()) switch(type) if(sd.is_open()) switch(type)
{ {
@ -925,9 +929,9 @@ try
{ {
if(ec) if(ec)
{ {
log::warning("socket(%p): close_notify: %s", log.warning("socket(%p): close_notify: %s",
s.get(), s.get(),
ec.message()); ec.message());
return; return;
} }
@ -935,9 +939,9 @@ try
s->sd.close(ec); s->sd.close(ec);
if(ec) if(ec)
log::warning("socket(%p): close(): %s", log.warning("socket(%p): close(): %s",
s.get(), s.get(),
ec.message()); ec.message());
}); });
break; break;
} }
@ -945,10 +949,10 @@ try
} }
catch(const boost::system::system_error &e) catch(const boost::system::system_error &e)
{ {
log::warning("socket(%p): disconnect: type: %d: %s", log.warning("socket(%p): disconnect: type: %d: %s",
(const void *)this, (const void *)this,
uint(type), uint(type),
e.what()); e.what());
throw; throw;
} }
@ -1037,7 +1041,7 @@ noexcept try
// user's callback. Otherwise they are passed up. // user's callback. Otherwise they are passed up.
if(!handle_error(ec)) if(!handle_error(ec))
{ {
log::debug("socket(%p): %s", this, ec.message()); log.debug("socket(%p): %s", this, ec.message());
return; return;
} }
@ -1048,16 +1052,16 @@ catch(const std::bad_weak_ptr &e)
// This handler may still be registered with asio after the socket destructs, so // This handler may still be registered with asio after the socket destructs, so
// the weak_ptr will indicate that fact. However, this is never intended and is // the weak_ptr will indicate that fact. However, this is never intended and is
// a debug assertion which should be corrected. // a debug assertion which should be corrected.
log::warning("socket(%p): belated callback to handler... (%s)", log.warning("socket(%p): belated callback to handler... (%s)",
this, this,
e.what()); e.what());
assert(0); assert(0);
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p): handle: %s", log.error("socket(%p): handle: %s",
this, this,
e.what()); e.what());
assert(0); assert(0);
} }
@ -1070,9 +1074,9 @@ noexcept try
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p): async handler: unhandled exception: %s", log.error("socket(%p): async handler: unhandled exception: %s",
this, this,
e.what()); e.what());
} }
bool bool
@ -1136,15 +1140,15 @@ noexcept try
} }
catch(const boost::system::system_error &e) catch(const boost::system::system_error &e)
{ {
log::error("socket(%p): handle_timeout: unexpected: %s\n", log.error("socket(%p): handle_timeout: unexpected: %s\n",
(const void *)this, (const void *)this,
e.what()); e.what());
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
log::error("socket(%p): handle timeout: %s", log.error("socket(%p): handle timeout: %s",
(const void *)this, (const void *)this,
e.what()); e.what());
} }
size_t size_t
@ -1503,11 +1507,11 @@ ircd::net::ipport::ipport(const std::string &host,
} }
else host4(*this) = address.to_v4().to_ulong(); else host4(*this) = address.to_v4().to_ulong();
log::debug("resolved remote %s:%u => %s %s", log.debug("resolved remote %s:%u => %s %s",
host, host,
net::port(*this), net::port(*this),
is_v6(*this)? "IP6" : "IP4", is_v6(*this)? "IP6" : "IP4",
string(*this)); string(*this));
} }
// //