feat: update logging, add high performance example

This commit is contained in:
2025-09-28 21:48:53 +02:00
parent 7a37901fb2
commit af46b5c2f4
4 changed files with 91 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ void ApiServer::setupWebSocket() {
JsonDocument doc;
DeserializationError err = deserializeJson(doc, (const char*)data, len);
if (!err) {
LOG_INFO("API", "Received event: " + String(doc["event"].as<String>()));
LOG_DEBUG("API", "Received event: " + String(doc["event"].as<String>()));
String eventName = doc["event"].as<String>();
String payloadStr;
if (doc["payload"].is<const char*>()) {

View File

@@ -19,7 +19,7 @@ ClusterManager::ClusterManager(NodeContext& ctx, TaskManager& taskMgr) : ctx(ctx
IPAddress ip = WiFi.localIP();
IPAddress mask = WiFi.subnetMask();
IPAddress bcast(ip[0] | ~mask[0], ip[1] | ~mask[1], ip[2] | ~mask[2], ip[3] | ~mask[3]);
LOG_INFO("Cluster", String("Broadcasting CLUSTER_EVENT to ") + bcast.toString() + " len=" + String(jsonStr->length()));
LOG_DEBUG("Cluster", String("Broadcasting CLUSTER_EVENT to ") + bcast.toString() + " len=" + String(jsonStr->length()));
this->ctx.udp->beginPacket(bcast, this->ctx.config.udp_port);
String msg = String(ClusterProtocol::CLUSTER_EVENT_MSG) + ":" + *jsonStr;
this->ctx.udp->write(msg.c_str());
@@ -204,7 +204,7 @@ void ClusterManager::onNodeInfo(const char* msg) {
}
}
} else {
LOG_DEBUG("Cluster", String("Failed to parse NODE_INFO JSON from ") + senderIP.toString());
LOG_WARN("Cluster", String("Failed to parse NODE_INFO JSON from ") + senderIP.toString());
}
}
}
@@ -216,11 +216,11 @@ void ClusterManager::onClusterEvent(const char* msg) {
LOG_DEBUG("Cluster", "CLUSTER_EVENT received with empty payload");
return;
}
LOG_INFO("Cluster", String("CLUSTER_EVENT raw from ") + ctx.udp->remoteIP().toString() + " len=" + String(strlen(jsonStart)));
LOG_DEBUG("Cluster", String("CLUSTER_EVENT raw from ") + ctx.udp->remoteIP().toString() + " len=" + String(strlen(jsonStart)));
JsonDocument doc;
DeserializationError err = deserializeJson(doc, jsonStart);
if (err) {
LOG_DEBUG("Cluster", String("Failed to parse CLUSTER_EVENT JSON from ") + ctx.udp->remoteIP().toString());
LOG_ERROR("Cluster", String("Failed to parse CLUSTER_EVENT JSON from ") + ctx.udp->remoteIP().toString());
return;
}
// Robust extraction of event and data
@@ -249,7 +249,7 @@ void ClusterManager::onClusterEvent(const char* msg) {
}
std::string eventKey(eventStr.c_str());
LOG_INFO("Cluster", String("Firing event '") + eventStr + "' with dataLen=" + String(data.length()));
LOG_DEBUG("Cluster", String("Firing event '") + eventStr + "' with dataLen=" + String(data.length()));
ctx.fire(eventKey, &data);
}