From ced3df67c6db14ed9413ef577c2d9b937ce8fc46 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 31 Aug 2022 12:40:43 -0700 Subject: [PATCH] modules/federation/send: Add m.txn log facility; improve debuglog related. --- modules/federation/send.cc | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/modules/federation/send.cc b/modules/federation/send.cc index ef9a9109d..14f279210 100644 --- a/modules/federation/send.cc +++ b/modules/federation/send.cc @@ -16,6 +16,12 @@ IRCD_MODULE "federation send" }; +log::log +txn_log +{ + "m.txn" +}; + m::resource send_resource { @@ -147,7 +153,7 @@ catch(const m::vm::error &e) log::error { - m::log, "Unhandled error processing txn '%s' from '%s' :%s :%s :%s", + txn_log, "Unhandled error processing txn '%s' from '%s' :%s :%s :%s", txn_id, request.node_id, e.what(), @@ -161,7 +167,7 @@ catch(const std::exception &e) { log::error { - m::log, "Unhandled error processing txn '%s' from '%s' :%s", + txn_log, "Unhandled error processing txn '%s' from '%s' :%s", txn_id, request.node_id, e.what(), @@ -191,17 +197,6 @@ handle_put(client &client, json::at<"origin"_>(request) }; - char rembuf[64]; - log::debug - { - m::log, "%s :%s | %s --> edus:%zu pdus:%zu", - txn_id, - origin, - string(rembuf, remote(client)), - json::get<"edus"_>(request).count(), - json::get<"pdus"_>(request).count(), - }; - if(origin && origin != request.node_id) throw m::ACCESS_DENIED { @@ -255,6 +250,21 @@ handle_put(client &client, client, http::ACCEPTED }; + char rembuf[96]; + log::logf + { + txn_log, log::level::DEBUG, + "%s %zu$B pdu:%zu %zu$B edu:%zu %zu %s :%s", + txn_id, + size(string_view(json::get<"pdus"_>(request))), + json::get<"pdus"_>(request).count(), + size(string_view(json::get<"edus"_>(request))), + json::get<"edus"_>(request).count(), + evals, + string(rembuf, remote(client)), + origin, + }; + char chunk[1536]; m::resource::response::chunked response {