0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd/modules: Migrate some log messages to new facilities.

This commit is contained in:
Jason Volk 2018-03-15 12:26:29 -07:00
parent bd60c2cd80
commit a48426e25d
7 changed files with 115 additions and 97 deletions

View file

@ -129,7 +129,7 @@ void
ircd::client::wait_all()
{
if(context.active())
log::warning
log::dwarning
{
"Joining %zu active of %zu remaining request contexts...",
context.active(),
@ -191,7 +191,7 @@ ircd::add_client(std::shared_ptr<socket> s)
{
if(unlikely(ircd::runlevel != ircd::runlevel::RUN))
{
log::warning
log::dwarning
{
"Refusing to add new client from %s in runlevel %s",
string(remote_ipport(*s)),
@ -374,10 +374,13 @@ bool
ircd::handle_ec_eof(client &client)
try
{
log::debug("socket(%p) local[%s] remote[%s] end of file",
client.sock.get(),
string(local(client)),
string(remote(client)));
log::debug
{
"socket(%p) local[%s] remote[%s] end of file",
client.sock.get(),
string(local(client)),
string(remote(client))
};
client.close(net::dc::SSL_NOTIFY, net::close_ignore);
return false;
@ -398,10 +401,13 @@ bool
ircd::handle_ec_short_read(client &client)
try
{
log::warning("socket(%p) local[%s] remote[%s] short_read",
client.sock.get(),
string(local(client)),
string(remote(client)));
log::dwarning
{
"socket(%p) local[%s] remote[%s] short_read",
client.sock.get(),
string(local(client)),
string(remote(client))
};
client.close(net::dc::RST, net::close_ignore);
return false;
@ -424,7 +430,7 @@ ircd::handle_ec_timeout(client &client)
try
{
assert(bool(client.sock));
log::debug
log::dwarning
{
"socket(%p) local[%s] remote[%s] disconnecting after inactivity timeout",
client.sock.get(),
@ -437,9 +443,12 @@ try
}
catch(const std::exception &e)
{
log::error("socket(%p) timeout: %s",
client.sock.get(),
e.what());
log::derror
{
"socket(%p) timeout: %s",
client.sock.get(),
e.what()
};
return false;
}
@ -450,11 +459,14 @@ bool
ircd::handle_ec_default(client &client,
const error_code &ec)
{
log::warning("socket(%p) local[%s] remote[%s] %s",
client.sock.get(),
string(local(client)),
string(remote(client)),
string(ec));
log::dwarning
{
"socket(%p) local[%s] remote[%s] %s",
client.sock.get(),
string(local(client)),
string(remote(client)),
string(ec)
};
client.close(net::dc::RST, net::close_ignore);
return false;
@ -482,10 +494,14 @@ noexcept try
}
catch(const std::exception &e)
{
log::critical("socket(%p) ~client(%p): %s",
sock.get(),
this,
e.what());
log::critical
{
"socket(%p) ~client(%p): %s",
sock.get(),
this,
e.what()
};
return;
}
@ -542,11 +558,14 @@ catch(const boost::system::system_error &e)
using boost::asio::error::get_ssl_category;
using boost::asio::error::get_misc_category;
log::debug("socket(%p) local[%s] remote[%s] error during request: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
string(e.code()));
log::derror
{
"socket(%p) local[%s] remote[%s] error during request: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
string(e.code())
};
const error_code &ec{e.code()};
const int &value{ec.value()};
@ -594,20 +613,25 @@ catch(const boost::system::system_error &e)
break;
}
log::error("socket(%p) (unexpected) %s: (%d) %s",
sock.get(),
ec.category().name(),
value,
ec.message());
log::error
{
"socket(%p) (unexpected) %s: (%d) %s",
sock.get(),
ec.category().name(),
value,
ec.message()
};
close(net::dc::RST, net::close_ignore);
return false;
}
catch(const std::exception &e)
{
log::error
log::critical
{
"client[%s] [500 Internal Error]: %s",
"socket(%p) local[%s] remote[%s]: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
e.what()
};
@ -644,14 +668,17 @@ try
pc.parsed += content_consumed;
assert(pc.parsed <= pc.read);
log::debug("socket(%p) local[%s] remote[%s] HTTP %s `%s' content-length:%zu have:%zu",
sock.get(),
string(local(*this)),
string(remote(*this)),
head.method,
head.path,
head.content_length,
content_consumed);
log::debug
{
"socket(%p) local[%s] remote[%s] HTTP %s `%s' content-length:%zu have:%zu",
sock.get(),
string(local(*this)),
string(remote(*this)),
head.method,
head.path,
head.content_length,
content_consumed
};
bool ret
{
@ -677,15 +704,6 @@ catch(const boost::system::system_error &e)
}
catch(const ircd::error &e)
{
log::error
{
"socket(%p) local[%s] remote[%s]: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
e.what()
};
resource::response
{
*this, e.what(), "text/html; charset=utf8", http::INTERNAL_SERVER_ERROR
@ -721,7 +739,7 @@ catch(http::error &e)
const std::string content{std::move(e.content)};
const std::string headers{std::move(e.headers)};
if(ircd::debugmode) log::error
log::derror
{
"socket(%p) local[%s] remote[%s] HTTP %u %s `%s' :%s",
sock.get(),
@ -773,12 +791,15 @@ ircd::client::discard_unconsumed(const http::request::head &head)
if(!unconsumed)
return;
log::debug("socket(%p) local[%s] remote[%s] discarding %zu unconsumed of %zu bytes content...",
sock.get(),
string(local(*this)),
string(remote(*this)),
unconsumed,
head.content_length);
log::debug
{
"socket(%p) local[%s] remote[%s] discarding %zu unconsumed of %zu bytes content...",
sock.get(),
string(local(*this)),
string(remote(*this)),
unconsumed,
head.content_length
};
content_consumed += net::discard_all(*sock, unconsumed);
assert(content_consumed == head.content_length);
@ -810,10 +831,7 @@ size_t
ircd::client::write_all(const const_buffer &buf)
{
if(unlikely(!sock))
throw error
{
"No socket to client."
};
throw error{"No socket to client."};
return net::write_all(*sock, buf);
}

View file

@ -888,7 +888,7 @@ ircd::ctx::prof::check_slice()
if(unlikely(settings.slice_warning > 0us && time_usage >= settings.slice_warning))
{
log::warning
log::dwarning
{
"context timeslice exceeded '%s' #%lu total: %06ld$us last: %lu$ns %lu$tsc",
name(c),
@ -920,7 +920,7 @@ ircd::ctx::prof::check_stack()
if(unlikely(stack_usage > stack_max * settings.stack_usage_warning))
{
log::warning
log::dwarning
{
"context stack usage ctx '%s' #%lu used %zu of %zu bytes",
name(c),

View file

@ -187,7 +187,7 @@ try
}
catch(const std::exception &e)
{
log::error
log::derror
{
"X-Matrix Authorization from %s: %s",
string(remote(client)),

View file

@ -600,11 +600,11 @@ ircd::server::peer::handle_open(link &link,
if(links.size() == 1)
err_set(eptr);
log.error("peer(%p) link(%p) [%s]: open: %s",
this,
&link,
string(remote),
what(eptr));
log.derror("peer(%p) link(%p) [%s]: open: %s",
this,
&link,
string(remote),
what(eptr));
if(op_fini)
{
@ -624,11 +624,11 @@ ircd::server::peer::handle_close(link &link,
std::exception_ptr eptr)
{
if(eptr)
log.error("peer(%p) link(%p) [%s]: close: %s",
this,
&link,
string(remote),
what(eptr));
log.derror("peer(%p) link(%p) [%s]: close: %s",
this,
&link,
string(remote),
what(eptr));
if(link.finished())
handle_finished(link);
@ -640,10 +640,10 @@ ircd::server::peer::handle_error(link &link,
{
assert(bool(eptr));
link.cancel_committed(eptr);
log.error("peer(%p) link(%p): %s",
this,
&link,
what(eptr));
log.derror("peer(%p) link(%p): %s",
this,
&link,
what(eptr));
link.close(net::dc::RST);
}
@ -682,11 +682,11 @@ ircd::server::peer::handle_error(link &link,
break;
}
log.error("peer(%p) link(%p) [%s]: error: %s",
this,
&link,
string(remote),
e.what());
log.derror("peer(%p) link(%p) [%s]: error: %s",
this,
&link,
string(remote),
e.what());
link.cancel_committed(std::make_exception_ptr(e));
link.close(net::dc::RST);
@ -867,9 +867,9 @@ try
}
catch(const std::exception &e)
{
log.error("peer(%p): error: %s",
this,
e.what());
log.derror("peer(%p): error: %s",
this,
e.what());
close();
}

View file

@ -60,7 +60,7 @@ try
}
catch(const ircd::ctx::interrupted &e)
{
ircd::log::debug
log::debug
{
"Sender worker interrupted..."
};
@ -90,7 +90,7 @@ catch(const ircd::ctx::interrupted &e)
}
catch(const std::exception &e)
{
ircd::log::error
log::error
{
"sender worker: %s", e.what()
};
@ -300,7 +300,7 @@ try
obj
};
if(code != http::OK) log::warning
if(code != http::OK) log::dwarning
{
"%u %s from %s for %s",
ushort(code),
@ -315,7 +315,7 @@ try
if(empty(error))
return;
log::error
log::derror
{
"Error from %s in %s for %s :%s",
string_view{node.id},
@ -329,7 +329,7 @@ try
}
catch(const http::error &e)
{
log::error
log::derror
{
"%u %s from %s for %s :%s",
ushort(e.code),
@ -343,7 +343,7 @@ catch(const http::error &e)
}
catch(const std::exception &e)
{
log::error
log::derror
{
"Error from %s for %s :%s",
string_view{node.id},
@ -377,7 +377,7 @@ recv_timeout(txn &txn)
assert(txn.node);
auto &node(*txn.node);
log::warning
log::dwarning
{
"Timeout to %s for txn %s",
string_view{node.id},

View file

@ -113,7 +113,7 @@ handle_m_receipt(const m::room::id &room_id,
continue;
}
log::warning
log::dwarning
{
"Unhandled m.receipt type '%s' to room '%s'",
type,

View file

@ -81,7 +81,7 @@ _handle_edu_m_typing(const m::event &event,
if(user_id.host() != at<"origin"_>(event))
{
log::warning
log::dwarning
{
"Ignoring %s from %s for user %s",
at<"type"_>(event),