diff --git a/src/Communication/CommunicationRouter/CommunicationRouter.cpp b/src/Communication/CommunicationRouter/CommunicationRouter.cpp index 1b10dd9..ab12e6b 100644 --- a/src/Communication/CommunicationRouter/CommunicationRouter.cpp +++ b/src/Communication/CommunicationRouter/CommunicationRouter.cpp @@ -109,9 +109,19 @@ void CommunicationRouter::begin() { _configManager.getMqttLogLevel(), _configManager.getSdLogLevel()); - Logging::setSubsystemMqttLevel("MQTTClient", Logging::NONE); - Logging::setSubsystemMqttLevel("CommRouter", Logging::WARNING); - Logging::setSubsystemMqttLevel("Logger", Logging::NONE); + // Suppress internal-plumbing subsystems on MQTT to prevent feedback loops + Logging::setSubsystemMqttLevel("MQTTClient", Logging::NONE); + Logging::setSubsystemMqttLevel("CommRouter", Logging::WARNING); + Logging::setSubsystemMqttLevel("Logger", Logging::NONE); + + // Per-subsystem MQTT caps: keep remote logs signal-rich, not noisy + Logging::setSubsystemMqttLevel("BellEngine", Logging::WARNING); // per-note strike spam + Logging::setSubsystemMqttLevel("OutputManager", Logging::WARNING); // per-note extinguish spam + Logging::setSubsystemMqttLevel("HealthMonitor", Logging::WARNING); // periodic check spam + Logging::setSubsystemMqttLevel("ConfigManager", Logging::WARNING); // NVS read spam + Logging::setSubsystemMqttLevel("Player", Logging::INFO); // state transitions useful + Logging::setSubsystemMqttLevel("Telemetry", Logging::INFO); // load data useful + Logging::setSubsystemMqttLevel("OTAManager", Logging::INFO); // update events important LOG_INFO(TAG, "MQTT transport initialised"); diff --git a/src/ConfigManager/ConfigManager.cpp b/src/ConfigManager/ConfigManager.cpp index d30bdd0..52e300c 100644 --- a/src/ConfigManager/ConfigManager.cpp +++ b/src/ConfigManager/ConfigManager.cpp @@ -229,7 +229,7 @@ String ConfigManager::readNVSString(const char* key, const String& defaultValue) String result = String(buffer); delete[] buffer; - LOG_VERBOSE(TAG, "ConfigManager - Read NVS key '%s': %s", key, result.c_str()); + LOG_DEBUG(TAG, "ConfigManager - NVS key '%s': %s", key, result.c_str()); return result; } @@ -328,23 +328,23 @@ bool ConfigManager::loadDeviceConfig() { bool ConfigManager::isHealthy() const { #if HAS_SD_CARD if (!sdInitialized) { - LOG_VERBOSE(TAG, "ConfigManager - ⚠️ Unhealthy - SD card not initialized"); + LOG_DEBUG(TAG, "ConfigManager - Unhealthy: SD card not initialized"); return false; } #endif if (deviceConfig.serial.isEmpty()) { - LOG_VERBOSE(TAG, "ConfigManager - ⚠️ Unhealthy - Serial not set (factory configuration required)"); + LOG_DEBUG(TAG, "ConfigManager - Unhealthy: Serial not set (factory configuration required)"); return false; } if (deviceConfig.hwFamily.isEmpty()) { - LOG_VERBOSE(TAG, "ConfigManager - ⚠️ Unhealthy - HW family not set (factory configuration required)"); + LOG_DEBUG(TAG, "ConfigManager - Unhealthy: HW family not set (factory configuration required)"); return false; } - + if (networkConfig.hostname.isEmpty()) { - LOG_VERBOSE(TAG, "ConfigManager - ⚠️ Unhealthy - Hostname not generated (initialization issue)"); + LOG_DEBUG(TAG, "ConfigManager - Unhealthy: Hostname not generated (initialization issue)"); return false; } @@ -523,7 +523,7 @@ void ConfigManager::updateBellOutputs(JsonVariant doc) { String key = String("b") + (i + 1); if (doc.containsKey(key)) { bellConfig.outputs[i] = doc[key].as() - 1; - LOG_VERBOSE(TAG, "ConfigManager - Bell %d output set to %d", i + 1, bellConfig.outputs[i]); + LOG_DEBUG(TAG, "ConfigManager - Bell %d output set to %d", i + 1, bellConfig.outputs[i]); } } LOG_DEBUG(TAG, "ConfigManager - Updated bell outputs"); @@ -576,7 +576,7 @@ void ConfigManager::saveFileToSD(const char* dirPath, const char* filename, cons file.print(data); file.close(); - LOG_VERBOSE(TAG, "ConfigManager - File %s saved successfully", fullPath.c_str()); + LOG_DEBUG(TAG, "ConfigManager - File %s saved successfully", fullPath.c_str()); } // Clock configuration methods and other remaining methods follow the same pattern... @@ -817,7 +817,7 @@ bool ConfigManager::saveClockState() { } saveFileToSD("/settings", "clockState.json", buffer); - LOG_VERBOSE(TAG, "ConfigManager - Clock state saved"); + LOG_DEBUG(TAG, "ConfigManager - Clock state saved"); return true; } @@ -1180,7 +1180,7 @@ bool ConfigManager::resetAllToDefaults() { if (SD.exists(filepath)) { if (SD.remove(filepath)) { - LOG_VERBOSE(TAG, "ConfigManager - ✅ Deleted: %s", filepath); + LOG_DEBUG(TAG, "ConfigManager - Deleted: %s", filepath); filesDeleted++; } else { LOG_ERROR(TAG, "ConfigManager - ❌ Failed to delete: %s", filepath); @@ -1188,7 +1188,7 @@ bool ConfigManager::resetAllToDefaults() { allDeleted = false; } } else { - LOG_VERBOSE(TAG, "ConfigManager - Skip (not found): %s", filepath); + LOG_DEBUG(TAG, "ConfigManager - Skip (not found): %s", filepath); } } @@ -1210,7 +1210,7 @@ bool ConfigManager::resetAllToDefaults() { if (!entry.isDirectory()) { if (SD.remove(entryPath.c_str())) { - LOG_VERBOSE(TAG, "ConfigManager - ✅ Deleted melody: %s", entryPath.c_str()); + LOG_DEBUG(TAG, "ConfigManager - Deleted melody: %s", entryPath.c_str()); melodiesDeleted++; } else { LOG_ERROR(TAG, "ConfigManager - ❌ Failed to delete melody: %s", entryPath.c_str()); @@ -1227,7 +1227,7 @@ bool ConfigManager::resetAllToDefaults() { // Try to remove the empty directory if (SD.rmdir("/melodies")) { - LOG_VERBOSE(TAG, "ConfigManager - ✅ Deleted /melodies directory"); + LOG_DEBUG(TAG, "ConfigManager - Deleted /melodies directory"); } else { LOG_WARNING(TAG, "ConfigManager - ⚠️ Could not delete /melodies directory (may not be empty)"); } @@ -1237,7 +1237,7 @@ bool ConfigManager::resetAllToDefaults() { filesFailed += melodiesFailed; } } else { - LOG_VERBOSE(TAG, "ConfigManager - /melodies directory not found"); + LOG_DEBUG(TAG, "ConfigManager - /melodies directory not found"); } // ════════════════════════════════════════════════════════════════════════════ diff --git a/src/ConfigManager/ConfigManager.hpp b/src/ConfigManager/ConfigManager.hpp index e4dd476..9523638 100644 --- a/src/ConfigManager/ConfigManager.hpp +++ b/src/ConfigManager/ConfigManager.hpp @@ -217,9 +217,9 @@ public: * All clock settings are loaded from SD card at startup. */ struct GeneralConfig { - uint8_t serialLogLevel = 5; - uint8_t sdLogLevel = 0; - uint8_t mqttLogLevel = 0; + uint8_t serialLogLevel = 3; // INFO + uint8_t sdLogLevel = 2; // WARNING (inactive until SD callback is wired) + uint8_t mqttLogLevel = 2; // WARNING bool mqttEnabled = true; // MQTT enabled by default String otaChannel = "stable"; // OTA release channel: "stable" | "beta" | "development" }; diff --git a/src/FirmwareValidator/FirmwareValidator.cpp b/src/FirmwareValidator/FirmwareValidator.cpp index 0bac348..4123388 100644 --- a/src/FirmwareValidator/FirmwareValidator.cpp +++ b/src/FirmwareValidator/FirmwareValidator.cpp @@ -360,7 +360,7 @@ bool FirmwareValidator::initializePartitions() { } bool FirmwareValidator::performBasicHealthCheck() { - LOG_VERBOSE(TAG, "🔍 Performing basic startup health check..."); + LOG_INFO(TAG, "Performing basic startup health check..."); // Check if health monitor is available if (!_healthMonitor) { @@ -381,14 +381,14 @@ bool FirmwareValidator::performBasicHealthCheck() { if (!bellEngineOk) LOG_ERROR(TAG, " - BellEngine: FAILED"); if (!outputManagerOk) LOG_ERROR(TAG, " - OutputManager: FAILED"); } else { - LOG_VERBOSE(TAG, "✅ Basic health check passed"); + LOG_INFO(TAG, "Basic health check passed"); } return basicHealthOk; } bool FirmwareValidator::performRuntimeHealthCheck() { - LOG_VERBOSE(TAG, "🔍 Performing comprehensive runtime health check..."); + LOG_DEBUG(TAG, "Performing comprehensive runtime health check..."); if (!_healthMonitor) { return false; diff --git a/src/HealthMonitor/HealthMonitor.cpp b/src/HealthMonitor/HealthMonitor.cpp index 514c5a6..4c2eacd 100644 --- a/src/HealthMonitor/HealthMonitor.cpp +++ b/src/HealthMonitor/HealthMonitor.cpp @@ -97,13 +97,10 @@ void HealthMonitor::monitoringLoop() { if (_player) { if (_player->_status != PlayerStatus::STOPPED) { - LOG_VERBOSE(TAG, "⏸️ Skipping health check during active playback"); return; } } - - LOG_VERBOSE(TAG, "🔍 Performing periodic health check..."); - + HealthStatus overallHealth = performFullHealthCheck(); // Log warnings for any unhealthy subsystems @@ -136,7 +133,7 @@ void HealthMonitor::monitoringLoop() { } } } else { - LOG_VERBOSE(TAG, "✅ All subsystems healthy"); + LOG_DEBUG(TAG, "✅ All subsystems healthy"); } } @@ -248,7 +245,7 @@ HealthStatus HealthMonitor::performFullHealthCheck() { #endif unsigned long elapsed = millis() - startTime; - LOG_VERBOSE(TAG, "🔍 Health check completed: %d systems in %lums", checkedSystems, elapsed); + LOG_DEBUG(TAG, "Health check: %d systems in %lums", checkedSystems, elapsed); return calculateOverallHealth(); } @@ -420,10 +417,10 @@ void HealthMonitor::updateSubsystemHealth(const String& name, HealthStatus statu it->second.lastError = error; it->second.lastCheck = millis(); - LOG_VERBOSE(TAG, "🔍 %s: %s %s", - name.c_str(), - healthStatusToString(status).c_str(), - error.isEmpty() ? "" : ("(" + error + ")").c_str()); + LOG_DEBUG(TAG, "%s: %s %s", + name.c_str(), + healthStatusToString(status).c_str(), + error.isEmpty() ? "" : ("(" + error + ")").c_str()); // Fire alert callback only on actual state change if (_alertCallback && status != previousStatus) { diff --git a/src/main.cpp b/src/main.cpp index 761a9de..2b1d544 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -501,10 +501,8 @@ void setup() bootOtaCheck(); // ───────────────────────────────────────────────────────────────────────────── - // Apply log level from config (loaded from SD) - uint8_t logLevel = configManager.getGeneralConfig().serialLogLevel; - Logging::setLevel((Logging::LogLevel)logLevel); - LOG_INFO(TAG, "Log level set to %d from configuration", logLevel); + // Log levels are applied by CommunicationRouter::begin() once all three channels + // (serial, MQTT, SD) and the MQTT callback are properly configured together. inputManager.begin(); inputManager.setFactoryResetMediumPressCallback(handleWiFiCredsReset); @@ -818,10 +816,9 @@ void loop() // Process UART command input from external devices (LCD panel, buttons) communication.loop(); - // 🔥 DEBUG: Log every 10 seconds to verify we're still running static unsigned long lastLog = 0; if (millis() - lastLog > 10000) { - LOG_DEBUG(TAG, "❤️ Loop alive | Free heap: %d bytes (%.1f KB) | Min free: %d | Largest block: %d", + LOG_VERBOSE(TAG, "❤️ Loop alive | Free heap: %d bytes (%.1f KB) | Min free: %d | Largest block: %d", ESP.getFreeHeap(), ESP.getFreeHeap() / 1024.0, ESP.getMinFreeHeap(),