feat: Add per-subsystem log tags to all firmware modules

Refactored logging system to require a TAG as first argument on all
LOG_* macros, enabling per-subsystem log filtering and cleaner output.
Each subsystem now defines its own TAG (e.g. "BellEngine", "Player").
Also overhauled Logging.hpp/cpp with improved level control and output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 17:31:28 +02:00
parent c656835d8e
commit fe6b1d871a
26 changed files with 1334 additions and 1074 deletions

View File

@@ -1,31 +1,33 @@
#include "ClientManager.hpp"
#define TAG "ClientManager"
#include "../Logging/Logging.hpp"
ClientManager::ClientManager() {
LOG_INFO("Client Manager initialized !");
LOG_INFO(TAG, "Client Manager initialized !");
}
ClientManager::~ClientManager() {
_clients.clear();
LOG_INFO("Client Manager destroyed");
LOG_INFO(TAG, "Client Manager destroyed");
}
void ClientManager::addClient(AsyncWebSocketClient* client, DeviceType deviceType) {
if (!isValidClient(client)) {
LOG_WARNING("Client Manager - Cannot add invalid client");
LOG_WARNING(TAG, "Client Manager - Cannot add invalid client");
return;
}
uint32_t clientId = client->id();
_clients[clientId] = ClientInfo(client, deviceType);
LOG_INFO("Client Manager - Client #%u added as %s device", clientId, deviceTypeToString(deviceType));
LOG_INFO(TAG, "Client Manager - Client #%u added as %s device", clientId, deviceTypeToString(deviceType));
}
void ClientManager::removeClient(uint32_t clientId) {
auto it = _clients.find(clientId);
if (it != _clients.end()) {
LOG_INFO("Client Manager - Client #%u removed (%s device)", clientId,
LOG_INFO(TAG, "Client Manager - Client #%u removed (%s device)", clientId,
deviceTypeToString(it->second.deviceType));
_clients.erase(it);
}
@@ -36,7 +38,7 @@ void ClientManager::updateClientType(uint32_t clientId, DeviceType deviceType) {
if (it != _clients.end()) {
DeviceType oldType = it->second.deviceType;
it->second.deviceType = deviceType;
LOG_INFO("Client Manager - Client #%u type updated from %s to %s", clientId,
LOG_INFO(TAG, "Client Manager - Client #%u type updated from %s to %s", clientId,
deviceTypeToString(oldType), deviceTypeToString(deviceType));
}
}
@@ -72,11 +74,11 @@ bool ClientManager::sendToClient(uint32_t clientId, const String& message) {
if (it != _clients.end() && isValidClient(it->second.client)) {
it->second.client->text(message);
updateClientLastSeen(clientId);
LOG_DEBUG("Client Manager - Message sent to client #%u: %s", clientId, message.c_str());
LOG_DEBUG(TAG, "Client Manager - Message sent to client #%u: %s", clientId, message.c_str());
return true;
}
LOG_WARNING("Client Manager - Failed to send message to client #%u - client not found or invalid", clientId);
LOG_WARNING(TAG, "Client Manager - Failed to send message to client #%u - client not found or invalid", clientId);
return false;
}
@@ -90,7 +92,7 @@ void ClientManager::sendToMasterClients(const String& message) {
count++;
}
}
LOG_DEBUG("Client Manager - Message sent to %d master client(s): %s", count, message.c_str());
LOG_DEBUG(TAG, "Client Manager - Message sent to %d master client(s): %s", count, message.c_str());
}
void ClientManager::sendToSecondaryClients(const String& message) {
@@ -103,7 +105,7 @@ void ClientManager::sendToSecondaryClients(const String& message) {
count++;
}
}
LOG_DEBUG("Client Manager - Message sent to %d secondary client(s): %s", count, message.c_str());
LOG_DEBUG(TAG, "Client Manager - Message sent to %d secondary client(s): %s", count, message.c_str());
}
void ClientManager::broadcastToAll(const String& message) {
@@ -115,14 +117,14 @@ void ClientManager::broadcastToAll(const String& message) {
count++;
}
}
LOG_DEBUG("Client Manager - Message broadcasted to %d client(s): %s", count, message.c_str());
LOG_DEBUG(TAG, "Client Manager - Message broadcasted to %d client(s): %s", count, message.c_str());
}
void ClientManager::cleanupDisconnectedClients() {
auto it = _clients.begin();
while (it != _clients.end()) {
if (!isValidClient(it->second.client)) {
LOG_DEBUG("Client Manager - Cleaning up disconnected client #%u", it->first);
LOG_DEBUG(TAG, "Client Manager - Cleaning up disconnected client #%u", it->first);
it->second.isConnected = false;
it = _clients.erase(it);
} else {