Normally when a plugin blocks an event, it will log a message. Especially when using plugins in stream, router, etc, this might be too verbose. In order to silence these logs, return an empty string for msg (or no msg at all).

This commit is contained in:
Doug Hoyte
2023-09-08 17:46:55 -04:00
parent 90494cb8b3
commit b2a128d2f3
5 changed files with 6 additions and 5 deletions

View File

@ -187,7 +187,7 @@ struct Router {
if (res == PluginEventSifterResult::Accept) {
router->writer.write({ std::move(evJson), EventSourceType::Stream, url });
} else {
LI << groupName << " / " << url << " : pluginDown blocked event " << evJson.at("id").get_string() << ": " << okMsg;
if (okMsg.size()) LI << groupName << " / " << url << " : pluginDown blocked event " << evJson.at("id").get_string() << ": " << okMsg;
}
}
@ -212,7 +212,7 @@ struct Router {
if (c.ws) c.ws->send(responseStr.data(), responseStr.size(), uWS::OpCode::TEXT, nullptr, nullptr, true);
}
} else {
LI << groupName << " : pluginUp blocked event " << evJson.at("id").get_string() << ": " << okMsg;
if (okMsg.size()) LI << groupName << " : pluginUp blocked event " << evJson.at("id").get_string() << ": " << okMsg;
}
}
};

View File

@ -72,7 +72,7 @@ void cmd_stream(const std::vector<std::string> &subArgs) {
downloadedIds.emplace(from_hex(evJson.at("id").get_string()));
writer.write({ std::move(evJson), EventSourceType::Stream, url });
} else {
LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
if (okMsg.size()) LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
}
} else {
LW << "Unexpected EVENT";

View File

@ -164,7 +164,7 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
if (res == PluginEventSifterResult::Accept) {
writer.write({ std::move(evJson), EventSourceType::Sync, url });
} else {
LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
if (okMsg.size()) LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
}
} else if (msg.at(0) == "EOSE") {
inFlightDown = false;

View File

@ -48,7 +48,7 @@ void RelayServer::runWriter(ThreadPool<MsgWriter>::Thread &thr) {
auto *flat = flatbuffers::GetRoot<NostrIndex::Event>(msg->flatStr.data());
auto eventIdHex = to_hex(sv(flat->id()));
LI << "[" << msg->connId << "] write policy blocked event " << eventIdHex << ": " << okMsg;
if (okMsg.size()) LI << "[" << msg->connId << "] write policy blocked event " << eventIdHex << ": " << okMsg;
sendOKResponse(msg->connId, eventIdHex, res == PluginEventSifterResult::ShadowReject, okMsg);
}