mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
ircd::server: Add loghead() and display request method/paths in some debug log msgs.
This commit is contained in:
parent
83dcfb05a0
commit
dbb965ce48
2 changed files with 46 additions and 3 deletions
|
@ -21,6 +21,9 @@ namespace ircd::server
|
||||||
size_t size(const out &);
|
size_t size(const out &);
|
||||||
size_t size_chunks(const in &);
|
size_t size_chunks(const in &);
|
||||||
|
|
||||||
|
string_view loghead(const mutable_buffer &out, const request &);
|
||||||
|
string_view loghead(const request &);
|
||||||
|
|
||||||
void submit(const hostport &, request &);
|
void submit(const hostport &, request &);
|
||||||
bool cancel(request &);
|
bool cancel(request &);
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,40 @@ ircd::server::submit(const hostport &hostport,
|
||||||
peer.submit(request);
|
peer.submit(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ircd::string_view
|
||||||
|
ircd::server::loghead(const mutable_buffer &buf,
|
||||||
|
const request &request)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(empty(request.in.head))
|
||||||
|
return "<no header>";
|
||||||
|
|
||||||
|
parse::buffer pb{request.out.head};
|
||||||
|
parse::capstan pc{pb};
|
||||||
|
pc.read += size(request.out.head);
|
||||||
|
const http::request::head head{pc};
|
||||||
|
return fmt::sprintf
|
||||||
|
{
|
||||||
|
buf, "%s %s", head.method, head.path
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
log::critical
|
||||||
|
{
|
||||||
|
log, "server::loghead(): %s", e.what()
|
||||||
|
};
|
||||||
|
|
||||||
|
return "<loghead error>";
|
||||||
|
}
|
||||||
|
|
||||||
|
ircd::string_view
|
||||||
|
ircd::server::loghead(const request &request)
|
||||||
|
{
|
||||||
|
thread_local char buf[256];
|
||||||
|
return loghead(buf, request);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// server/peer.h
|
// server/peer.h
|
||||||
|
@ -776,10 +810,13 @@ noexcept try
|
||||||
{
|
{
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "peer(%p) link(%p) tag(%p) done wt:%zu rt:%zu hr:%zu cr:%zu cl:%zu; %zu more in queue",
|
log, "peer(%p) link(%p) tag(%p) [%s] done wt:%zu rt:%zu hr:%zu cr:%zu cl:%zu; %zu more in queue",
|
||||||
this,
|
this,
|
||||||
&link,
|
&link,
|
||||||
&tag,
|
&tag,
|
||||||
|
tag.request?
|
||||||
|
loghead(*tag.request):
|
||||||
|
"<no request>"_sv,
|
||||||
tag.write_size(),
|
tag.write_size(),
|
||||||
tag.read_size(),
|
tag.read_size(),
|
||||||
tag.state.head_read,
|
tag.state.head_read,
|
||||||
|
@ -1489,13 +1526,16 @@ 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",
|
log, "peer(%p) link(%p) starting on tag(%p) %zu of %zu: wt:%zu [%s]",
|
||||||
peer,
|
peer,
|
||||||
this,
|
this,
|
||||||
&tag,
|
&tag,
|
||||||
tag_committed(),
|
tag_committed(),
|
||||||
tag_count(),
|
tag_count(),
|
||||||
tag.write_size()
|
tag.write_size(),
|
||||||
|
tag.request?
|
||||||
|
loghead(*tag.request):
|
||||||
|
"<no attached request>"_sv
|
||||||
};
|
};
|
||||||
|
|
||||||
while(tag.write_remaining())
|
while(tag.write_remaining())
|
||||||
|
|
Loading…
Reference in a new issue