diff options
author | Sadie Powell <sadie@witchery.services> | 2024-03-08 12:24:44 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-03-08 12:24:44 +0000 |
commit | 1d0a836a2ec3614b4eb94716f57a0d4a646cf860 (patch) | |
tree | e7391569968473b43f6d1f6c648890fe6d00338d /src | |
parent | 46b70648342daf1d3c482f24b14c125a31c0bfca (diff) |
Improve protocol debug messages.
Diffstat (limited to 'src')
-rw-r--r-- | src/process.cpp | 29 | ||||
-rw-r--r-- | src/uplink.cpp | 28 |
2 files changed, 44 insertions, 13 deletions
diff --git a/src/process.cpp b/src/process.cpp index 51930c1fa..eea5bcfe6 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -18,35 +18,40 @@ void Anope::Process(const Anope::string &buffer) { - /* If debugging, log the buffer */ - Log(LOG_RAWIO) << "Received: " << buffer; - if (buffer.empty()) return; Anope::map<Anope::string> tags; Anope::string source, command; std::vector<Anope::string> params; - if (!IRCD->Parse(buffer, tags, source, command, params)) return; + Log(LOG_RAWIO) << "Received " << buffer; if (Anope::ProtocolDebug) { if (tags.empty()) - Log() << "No tags"; + Log() << "\tNo tags"; + else + { + for (const auto &[tname, tvalue] : tags) + Log() << "\tTag " << tname << ": " << tvalue; + } + + if (source.empty()) + Log() << "\tNo source"; else - for (Anope::map<Anope::string>::const_iterator it = tags.begin(); it != tags.end(); ++it) - Log() << "tags " << it->first << ": " << it->second; + Log() << "\tSource: " << source; - Log() << "Source : " << (source.empty() ? "No source" : source); - Log() << "Command: " << command; + Log() << "\tCommand: " << command; if (params.empty()) - Log() << "No params"; + Log() << "\tNo params"; else - for (unsigned i = 0; i < params.size(); ++i) - Log() << "params " << i << ": " << params[i]; + { + for (size_t i = 0; i < params.size(); ++i) + Log() << "\tParam " << i << ": " << params[i]; + } } static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; diff --git a/src/uplink.cpp b/src/uplink.cpp index baa878db3..7e3322009 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -74,7 +74,33 @@ void Uplink::SendInternal(const Anope::map<Anope::string> &tags, const MessageSo return; UplinkSock->Write(message); - Log(LOG_RAWIO) << "Sent: " << message; + + Log(LOG_RAWIO) << "Sent " << message; + if (Anope::ProtocolDebug) + { + if (tags.empty()) + Log() << "\tNo tags"; + else + { + for (const auto &[tname, tvalue] : tags) + Log() << "\tTag " << tname << ": " << tvalue; + } + + if (source.GetSource().empty()) + Log() << "\tNo source"; + else + Log() << "\tSource: " << source.GetSource(); + + Log() << "\tCommand: " << command; + + if (params.empty()) + Log() << "\tNo params"; + else + { + for (size_t i = 0; i < params.size(); ++i) + Log() << "\tParam " << i << ": " << params[i]; + } + } } UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].protocol), ConnectionSocket(), BufferedSocket() |