mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 07:20:55 +01:00
ircd::server: Use a uniform log prefix for link related.
This commit is contained in:
parent
d6374466f3
commit
e0b4dc4450
2 changed files with 73 additions and 48 deletions
|
@ -11,6 +11,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define HAVE_IRCD_SERVER_LINK_H
|
#define HAVE_IRCD_SERVER_LINK_H
|
||||||
|
|
||||||
|
namespace ircd::server
|
||||||
|
{
|
||||||
|
string_view loghead(const mutable_buffer &out, const link &);
|
||||||
|
string_view loghead(const link &);
|
||||||
|
}
|
||||||
|
|
||||||
/// A single connection to a remote peer.
|
/// A single connection to a remote peer.
|
||||||
///
|
///
|
||||||
struct ircd::server::link
|
struct ircd::server::link
|
||||||
|
|
115
ircd/server.cc
115
ircd/server.cc
|
@ -379,7 +379,7 @@ ircd::string_view
|
||||||
ircd::server::loghead(const link &link,
|
ircd::server::loghead(const link &link,
|
||||||
const request &request)
|
const request &request)
|
||||||
{
|
{
|
||||||
thread_local char buf[256];
|
thread_local char buf[512];
|
||||||
return loghead(buf, link, request);
|
return loghead(buf, link, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,9 +390,8 @@ ircd::server::loghead(const mutable_buffer &buf,
|
||||||
{
|
{
|
||||||
return fmt::sprintf
|
return fmt::sprintf
|
||||||
{
|
{
|
||||||
buf, "peer[%lu] link[%lu] %s",
|
buf, "%s %s",
|
||||||
link.peer? link.peer->id : 0UL,
|
loghead(link),
|
||||||
link.id,
|
|
||||||
loghead(request)
|
loghead(request)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -400,7 +399,7 @@ ircd::server::loghead(const mutable_buffer &buf,
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
ircd::server::loghead(const request &request)
|
ircd::server::loghead(const request &request)
|
||||||
{
|
{
|
||||||
thread_local char buf[256];
|
thread_local char buf[512];
|
||||||
return loghead(buf, request);
|
return loghead(buf, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,9 +851,8 @@ ircd::server::peer::handle_open(link &link,
|
||||||
thread_local char rembuf[64];
|
thread_local char rembuf[64];
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) [%s]: open: %s",
|
log, "%s [%s]: open: %s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
string(rembuf, remote),
|
string(rembuf, remote),
|
||||||
what(eptr)
|
what(eptr)
|
||||||
};
|
};
|
||||||
|
@ -881,9 +879,8 @@ ircd::server::peer::handle_close(link &link,
|
||||||
if(eptr)
|
if(eptr)
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) [%s]: close: %s",
|
log, "%s [%s]: close: %s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
string(rembuf, remote),
|
string(rembuf, remote),
|
||||||
what(eptr)
|
what(eptr)
|
||||||
};
|
};
|
||||||
|
@ -900,9 +897,8 @@ ircd::server::peer::handle_error(link &link,
|
||||||
link.cancel_committed(eptr);
|
link.cancel_committed(eptr);
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p): %s",
|
log, "%s :%s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
what(eptr)
|
what(eptr)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -932,9 +928,8 @@ ircd::server::peer::handle_error(link &link,
|
||||||
case asio::error::eof:
|
case asio::error::eof:
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) [%s]: %s",
|
log, "%s [%s]: %s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
string(rembuf, remote),
|
string(rembuf, remote),
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
|
@ -948,9 +943,8 @@ ircd::server::peer::handle_error(link &link,
|
||||||
|
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) [%s]: %s",
|
log, "%s [%s]: %s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
string(rembuf, remote),
|
string(rembuf, remote),
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
|
@ -981,10 +975,8 @@ noexcept try
|
||||||
{
|
{
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) tag(%p) [%s] => [%u] done wt:%zu rt:%zu hr:%zu cr:%zu cl:%zu; %zu more in queue",
|
log, "%s [%s] => [%u] done wt:%zu rt:%zu hr:%zu cr:%zu cl:%zu; %zu more in queue",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
|
||||||
&tag,
|
|
||||||
tag.request?
|
tag.request?
|
||||||
loghead(*tag.request):
|
loghead(*tag.request):
|
||||||
"<no request>"_sv,
|
"<no request>"_sv,
|
||||||
|
@ -1004,10 +996,9 @@ catch(const std::exception &e)
|
||||||
{
|
{
|
||||||
log::critical
|
log::critical
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) tag(%p) done; %s",
|
log, "%s tag:%lu done; %s",
|
||||||
this,
|
loghead(link),
|
||||||
&link,
|
tag.state.id,
|
||||||
&tag,
|
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1045,8 +1036,8 @@ ircd::server::peer::handle_head_recv(const link &link,
|
||||||
server_version = std::string{head.server};
|
server_version = std::string{head.server};
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) learned %s is '%s'",
|
log, "%s learned %s is '%s'",
|
||||||
this,
|
loghead(link),
|
||||||
string(rembuf, remote),
|
string(rembuf, remote),
|
||||||
server_version,
|
server_version,
|
||||||
};
|
};
|
||||||
|
@ -1087,9 +1078,9 @@ ircd::server::peer::disperse_uncommitted(link &link)
|
||||||
const auto &tag{*it};
|
const auto &tag{*it};
|
||||||
log::warning
|
log::warning
|
||||||
{
|
{
|
||||||
log, "peer(%p) failed to resubmit tag(%p): %s",
|
log, "%s failed to resubmit tag:%lu :%s",
|
||||||
this,
|
loghead(link),
|
||||||
&tag,
|
tag.state.id,
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1115,9 +1106,9 @@ ircd::server::peer::del(link &link)
|
||||||
thread_local char rembuf[64];
|
thread_local char rembuf[64];
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) removing link(%p) %zu of %zu to %s",
|
log, "%s removing from peer(%p) %zu of %zu to %s",
|
||||||
|
loghead(link),
|
||||||
this,
|
this,
|
||||||
&link,
|
|
||||||
std::distance(begin(links), it),
|
std::distance(begin(links), it),
|
||||||
links.size(),
|
links.size(),
|
||||||
string(rembuf, remote)
|
string(rembuf, remote)
|
||||||
|
@ -1623,6 +1614,33 @@ ircd::server::link::tag_commit_max_default
|
||||||
decltype(ircd::server::link::ids)
|
decltype(ircd::server::link::ids)
|
||||||
ircd::server::link::ids;
|
ircd::server::link::ids;
|
||||||
|
|
||||||
|
ircd::string_view
|
||||||
|
ircd::server::loghead(const link &link)
|
||||||
|
{
|
||||||
|
thread_local char buf[512];
|
||||||
|
return loghead(buf, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
ircd::string_view
|
||||||
|
ircd::server::loghead(const mutable_buffer &buf,
|
||||||
|
const link &link)
|
||||||
|
{
|
||||||
|
thread_local char rembuf[2][64];
|
||||||
|
return fmt::sprintf
|
||||||
|
{
|
||||||
|
buf, "socket:%lu local[%s] remote[%s] link:%lu peer:%lu",
|
||||||
|
link.socket?
|
||||||
|
link.socket->id : 0UL,
|
||||||
|
link.socket?
|
||||||
|
string(rembuf[0], local_ipport(*link.socket)): string_view{},
|
||||||
|
link.socket?
|
||||||
|
string(rembuf[0], remote_ipport(*link.socket)): string_view{},
|
||||||
|
link.id,
|
||||||
|
link.peer?
|
||||||
|
link.peer->id: 0UL,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// link::link
|
// link::link
|
||||||
//
|
//
|
||||||
|
@ -1871,8 +1889,8 @@ ircd::server::link::handle_writable_success()
|
||||||
{
|
{
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "link(%p) discarding canceled:%d abandoned:%d uncommitted tag %zu of %zu",
|
log, "%s discarding canceled:%d abandoned:%d uncommitted tag %zu of %zu",
|
||||||
this,
|
loghead(*this),
|
||||||
tag.canceled(),
|
tag.canceled(),
|
||||||
tag.abandoned(),
|
tag.abandoned(),
|
||||||
tag_committed(),
|
tag_committed(),
|
||||||
|
@ -1887,9 +1905,9 @@ ircd::server::link::handle_writable_success()
|
||||||
{
|
{
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "link(%p) closing to interrupt canceled committed tag(%p) of %zu",
|
log, "%s closing to interrupt canceled committed tag:%lu of %zu",
|
||||||
this,
|
loghead(*this),
|
||||||
&tag,
|
tag.state.id,
|
||||||
tag_count()
|
tag_count()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1920,10 +1938,9 @@ ircd::server::link::process_write(tag &tag)
|
||||||
if(!tag.committed())
|
if(!tag.committed())
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) starting on tag(%p) %zu of %zu: wt:%zu [%s]",
|
log, "%s starting on tag:%lu %zu of %zu: wt:%zu [%s]",
|
||||||
peer,
|
loghead(*this),
|
||||||
this,
|
tag.state.id,
|
||||||
&tag,
|
|
||||||
tag_committed(),
|
tag_committed(),
|
||||||
tag_count(),
|
tag_count(),
|
||||||
tag.write_size(),
|
tag.write_size(),
|
||||||
|
@ -2083,9 +2100,9 @@ try
|
||||||
{
|
{
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "link(%p) closing to interrupt canceled committed tag(%p) of %zu",
|
log, "%s closing to interrupt canceled committed tag:%lu of %zu",
|
||||||
this,
|
loghead(*this),
|
||||||
&tag,
|
tag.state.id,
|
||||||
tag_count()
|
tag_count()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2224,7 +2241,9 @@ ircd::server::link::discard_read()
|
||||||
|
|
||||||
log::warning
|
log::warning
|
||||||
{
|
{
|
||||||
log, "%s", string_view{msg}
|
log, "%s %s",
|
||||||
|
loghead(*this),
|
||||||
|
string_view{msg},
|
||||||
};
|
};
|
||||||
|
|
||||||
// just in case so this doesn't get loopy with discarding zero with
|
// just in case so this doesn't get loopy with discarding zero with
|
||||||
|
|
Loading…
Reference in a new issue