refactor(Logging): calibrate default levels and reduce playback noise
Serial default VERBOSE→INFO, MQTT default NONE→WARNING, SD NONE→WARNING. Per-subsystem MQTT caps added in CommunicationRouter: BellEngine/ OutputManager/HealthMonitor/ConfigManager at WARNING to silence per-note and per-poll spam; Player/Telemetry/OTAManager at INFO to keep state transitions visible. Remove early Logging::setLevel() call in main.cpp — CommunicationRouter applies all three channels once the MQTT callback is wired. Loop heartbeat downgraded DEBUG→VERBOSE. HealthMonitor polling noise (skipping/performing lines) removed; subsystem status and completion lines VERBOSE→DEBUG. FirmwareValidator boot-path checks VERBOSE→INFO (one-shot, worth seeing). ConfigManager isHealthy() false-branches and NVS read trace VERBOSE→DEBUG. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -109,10 +109,20 @@ void CommunicationRouter::begin() {
|
|||||||
_configManager.getMqttLogLevel(),
|
_configManager.getMqttLogLevel(),
|
||||||
_configManager.getSdLogLevel());
|
_configManager.getSdLogLevel());
|
||||||
|
|
||||||
|
// Suppress internal-plumbing subsystems on MQTT to prevent feedback loops
|
||||||
Logging::setSubsystemMqttLevel("MQTTClient", Logging::NONE);
|
Logging::setSubsystemMqttLevel("MQTTClient", Logging::NONE);
|
||||||
Logging::setSubsystemMqttLevel("CommRouter", Logging::WARNING);
|
Logging::setSubsystemMqttLevel("CommRouter", Logging::WARNING);
|
||||||
Logging::setSubsystemMqttLevel("Logger", Logging::NONE);
|
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");
|
LOG_INFO(TAG, "MQTT transport initialised");
|
||||||
|
|
||||||
// ── HTTP ─────────────────────────────────────────────────────────────────
|
// ── HTTP ─────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ String ConfigManager::readNVSString(const char* key, const String& defaultValue)
|
|||||||
String result = String(buffer);
|
String result = String(buffer);
|
||||||
delete[] 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,23 +328,23 @@ bool ConfigManager::loadDeviceConfig() {
|
|||||||
bool ConfigManager::isHealthy() const {
|
bool ConfigManager::isHealthy() const {
|
||||||
#if HAS_SD_CARD
|
#if HAS_SD_CARD
|
||||||
if (!sdInitialized) {
|
if (!sdInitialized) {
|
||||||
LOG_VERBOSE(TAG, "ConfigManager - ⚠️ Unhealthy - SD card not initialized");
|
LOG_DEBUG(TAG, "ConfigManager - Unhealthy: SD card not initialized");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (deviceConfig.serial.isEmpty()) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceConfig.hwFamily.isEmpty()) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkConfig.hostname.isEmpty()) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ void ConfigManager::updateBellOutputs(JsonVariant doc) {
|
|||||||
String key = String("b") + (i + 1);
|
String key = String("b") + (i + 1);
|
||||||
if (doc.containsKey(key)) {
|
if (doc.containsKey(key)) {
|
||||||
bellConfig.outputs[i] = doc[key].as<uint16_t>() - 1;
|
bellConfig.outputs[i] = doc[key].as<uint16_t>() - 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");
|
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.print(data);
|
||||||
file.close();
|
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...
|
// Clock configuration methods and other remaining methods follow the same pattern...
|
||||||
@@ -817,7 +817,7 @@ bool ConfigManager::saveClockState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveFileToSD("/settings", "clockState.json", buffer);
|
saveFileToSD("/settings", "clockState.json", buffer);
|
||||||
LOG_VERBOSE(TAG, "ConfigManager - Clock state saved");
|
LOG_DEBUG(TAG, "ConfigManager - Clock state saved");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1180,7 +1180,7 @@ bool ConfigManager::resetAllToDefaults() {
|
|||||||
|
|
||||||
if (SD.exists(filepath)) {
|
if (SD.exists(filepath)) {
|
||||||
if (SD.remove(filepath)) {
|
if (SD.remove(filepath)) {
|
||||||
LOG_VERBOSE(TAG, "ConfigManager - ✅ Deleted: %s", filepath);
|
LOG_DEBUG(TAG, "ConfigManager - Deleted: %s", filepath);
|
||||||
filesDeleted++;
|
filesDeleted++;
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(TAG, "ConfigManager - ❌ Failed to delete: %s", filepath);
|
LOG_ERROR(TAG, "ConfigManager - ❌ Failed to delete: %s", filepath);
|
||||||
@@ -1188,7 +1188,7 @@ bool ConfigManager::resetAllToDefaults() {
|
|||||||
allDeleted = false;
|
allDeleted = false;
|
||||||
}
|
}
|
||||||
} else {
|
} 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 (!entry.isDirectory()) {
|
||||||
if (SD.remove(entryPath.c_str())) {
|
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++;
|
melodiesDeleted++;
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(TAG, "ConfigManager - ❌ Failed to delete melody: %s", entryPath.c_str());
|
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
|
// Try to remove the empty directory
|
||||||
if (SD.rmdir("/melodies")) {
|
if (SD.rmdir("/melodies")) {
|
||||||
LOG_VERBOSE(TAG, "ConfigManager - ✅ Deleted /melodies directory");
|
LOG_DEBUG(TAG, "ConfigManager - Deleted /melodies directory");
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING(TAG, "ConfigManager - ⚠️ Could not delete /melodies directory (may not be empty)");
|
LOG_WARNING(TAG, "ConfigManager - ⚠️ Could not delete /melodies directory (may not be empty)");
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1237,7 @@ bool ConfigManager::resetAllToDefaults() {
|
|||||||
filesFailed += melodiesFailed;
|
filesFailed += melodiesFailed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_VERBOSE(TAG, "ConfigManager - /melodies directory not found");
|
LOG_DEBUG(TAG, "ConfigManager - /melodies directory not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ════════════════════════════════════════════════════════════════════════════
|
// ════════════════════════════════════════════════════════════════════════════
|
||||||
|
|||||||
@@ -217,9 +217,9 @@ public:
|
|||||||
* All clock settings are loaded from SD card at startup.
|
* All clock settings are loaded from SD card at startup.
|
||||||
*/
|
*/
|
||||||
struct GeneralConfig {
|
struct GeneralConfig {
|
||||||
uint8_t serialLogLevel = 5;
|
uint8_t serialLogLevel = 3; // INFO
|
||||||
uint8_t sdLogLevel = 0;
|
uint8_t sdLogLevel = 2; // WARNING (inactive until SD callback is wired)
|
||||||
uint8_t mqttLogLevel = 0;
|
uint8_t mqttLogLevel = 2; // WARNING
|
||||||
bool mqttEnabled = true; // MQTT enabled by default
|
bool mqttEnabled = true; // MQTT enabled by default
|
||||||
String otaChannel = "stable"; // OTA release channel: "stable" | "beta" | "development"
|
String otaChannel = "stable"; // OTA release channel: "stable" | "beta" | "development"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ bool FirmwareValidator::initializePartitions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FirmwareValidator::performBasicHealthCheck() {
|
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
|
// Check if health monitor is available
|
||||||
if (!_healthMonitor) {
|
if (!_healthMonitor) {
|
||||||
@@ -381,14 +381,14 @@ bool FirmwareValidator::performBasicHealthCheck() {
|
|||||||
if (!bellEngineOk) LOG_ERROR(TAG, " - BellEngine: FAILED");
|
if (!bellEngineOk) LOG_ERROR(TAG, " - BellEngine: FAILED");
|
||||||
if (!outputManagerOk) LOG_ERROR(TAG, " - OutputManager: FAILED");
|
if (!outputManagerOk) LOG_ERROR(TAG, " - OutputManager: FAILED");
|
||||||
} else {
|
} else {
|
||||||
LOG_VERBOSE(TAG, "✅ Basic health check passed");
|
LOG_INFO(TAG, "Basic health check passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return basicHealthOk;
|
return basicHealthOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FirmwareValidator::performRuntimeHealthCheck() {
|
bool FirmwareValidator::performRuntimeHealthCheck() {
|
||||||
LOG_VERBOSE(TAG, "🔍 Performing comprehensive runtime health check...");
|
LOG_DEBUG(TAG, "Performing comprehensive runtime health check...");
|
||||||
|
|
||||||
if (!_healthMonitor) {
|
if (!_healthMonitor) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -97,13 +97,10 @@ void HealthMonitor::monitoringLoop() {
|
|||||||
|
|
||||||
if (_player) {
|
if (_player) {
|
||||||
if (_player->_status != PlayerStatus::STOPPED) {
|
if (_player->_status != PlayerStatus::STOPPED) {
|
||||||
LOG_VERBOSE(TAG, "⏸️ Skipping health check during active playback");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_VERBOSE(TAG, "🔍 Performing periodic health check...");
|
|
||||||
|
|
||||||
HealthStatus overallHealth = performFullHealthCheck();
|
HealthStatus overallHealth = performFullHealthCheck();
|
||||||
|
|
||||||
// Log warnings for any unhealthy subsystems
|
// Log warnings for any unhealthy subsystems
|
||||||
@@ -136,7 +133,7 @@ void HealthMonitor::monitoringLoop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_VERBOSE(TAG, "✅ All subsystems healthy");
|
LOG_DEBUG(TAG, "✅ All subsystems healthy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +245,7 @@ HealthStatus HealthMonitor::performFullHealthCheck() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned long elapsed = millis() - startTime;
|
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();
|
return calculateOverallHealth();
|
||||||
}
|
}
|
||||||
@@ -420,7 +417,7 @@ void HealthMonitor::updateSubsystemHealth(const String& name, HealthStatus statu
|
|||||||
it->second.lastError = error;
|
it->second.lastError = error;
|
||||||
it->second.lastCheck = millis();
|
it->second.lastCheck = millis();
|
||||||
|
|
||||||
LOG_VERBOSE(TAG, "🔍 %s: %s %s",
|
LOG_DEBUG(TAG, "%s: %s %s",
|
||||||
name.c_str(),
|
name.c_str(),
|
||||||
healthStatusToString(status).c_str(),
|
healthStatusToString(status).c_str(),
|
||||||
error.isEmpty() ? "" : ("(" + error + ")").c_str());
|
error.isEmpty() ? "" : ("(" + error + ")").c_str());
|
||||||
|
|||||||
+3
-6
@@ -501,10 +501,8 @@ void setup()
|
|||||||
bootOtaCheck();
|
bootOtaCheck();
|
||||||
// ─────────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
// Apply log level from config (loaded from SD)
|
// Log levels are applied by CommunicationRouter::begin() once all three channels
|
||||||
uint8_t logLevel = configManager.getGeneralConfig().serialLogLevel;
|
// (serial, MQTT, SD) and the MQTT callback are properly configured together.
|
||||||
Logging::setLevel((Logging::LogLevel)logLevel);
|
|
||||||
LOG_INFO(TAG, "Log level set to %d from configuration", logLevel);
|
|
||||||
|
|
||||||
inputManager.begin();
|
inputManager.begin();
|
||||||
inputManager.setFactoryResetMediumPressCallback(handleWiFiCredsReset);
|
inputManager.setFactoryResetMediumPressCallback(handleWiFiCredsReset);
|
||||||
@@ -818,10 +816,9 @@ void loop()
|
|||||||
// Process UART command input from external devices (LCD panel, buttons)
|
// Process UART command input from external devices (LCD panel, buttons)
|
||||||
communication.loop();
|
communication.loop();
|
||||||
|
|
||||||
// 🔥 DEBUG: Log every 10 seconds to verify we're still running
|
|
||||||
static unsigned long lastLog = 0;
|
static unsigned long lastLog = 0;
|
||||||
if (millis() - lastLog > 10000) {
|
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(),
|
||||||
ESP.getFreeHeap() / 1024.0,
|
ESP.getFreeHeap() / 1024.0,
|
||||||
ESP.getMinFreeHeap(),
|
ESP.getMinFreeHeap(),
|
||||||
|
|||||||
Reference in New Issue
Block a user