Redundant Log Messages Cleanup (#8944)

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
J. Nick Koston 2025-05-29 04:36:23 -05:00 committed by GitHub
parent 959a8b91bd
commit fd72a64053
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 48 additions and 50 deletions

View File

@ -157,7 +157,7 @@ void APIServer::loop() {
const uint32_t now = millis();
if (!this->is_connected()) {
if (now - this->last_connected_ > this->reboot_timeout_) {
ESP_LOGE(TAG, "No client connected to API. Rebooting...");
ESP_LOGE(TAG, "No client connected; rebooting");
App.reboot();
}
this->status_set_warning();

View File

@ -29,7 +29,7 @@ void CaptivePortal::handle_config(AsyncWebServerRequest *request) {
void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
std::string ssid = request->arg("ssid").c_str();
std::string psk = request->arg("psk").c_str();
ESP_LOGI(TAG, "Captive Portal Requested WiFi Settings Change:");
ESP_LOGI(TAG, "Requested WiFi Settings Change:");
ESP_LOGI(TAG, " SSID='%s'", ssid.c_str());
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.c_str());
wifi::global_wifi_component->save_wifi_sta(ssid, psk);

View File

@ -15,10 +15,10 @@ void DeepSleepComponent::setup() {
const optional<uint32_t> run_duration = get_run_duration_();
if (run_duration.has_value()) {
ESP_LOGI(TAG, "Scheduling Deep Sleep to start in %" PRIu32 " ms", *run_duration);
ESP_LOGI(TAG, "Scheduling in %" PRIu32 " ms", *run_duration);
this->set_timeout(*run_duration, [this]() { this->begin_sleep(); });
} else {
ESP_LOGD(TAG, "Not scheduling Deep Sleep, as no run duration is configured.");
ESP_LOGD(TAG, "Not scheduling; no run duration configured");
}
}
@ -57,7 +57,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
return;
}
ESP_LOGI(TAG, "Beginning Deep Sleep");
ESP_LOGI(TAG, "Beginning sleep");
if (this->sleep_duration_.has_value()) {
ESP_LOGI(TAG, "Sleeping for %" PRId64 "us", *this->sleep_duration_);
}

View File

@ -59,7 +59,7 @@ bool DeepSleepComponent::prepare_to_sleep_() {
// Defer deep sleep until inactive
if (!this->next_enter_deep_sleep_) {
this->status_set_warning();
ESP_LOGW(TAG, "Waiting wakeup pin state change to enter deep sleep...");
ESP_LOGW(TAG, "Waiting for wakeup pin state change");
}
this->next_enter_deep_sleep_ = true;
return false;

View File

@ -10,7 +10,7 @@ static const char *const TAG = "factory_reset.button";
void FactoryResetButton::dump_config() { LOG_BUTTON("", "Factory Reset Button", this); }
void FactoryResetButton::press_action() {
ESP_LOGI(TAG, "Resetting to factory defaults...");
ESP_LOGI(TAG, "Resetting...");
// Let MQTT settle a bit
delay(100); // NOLINT
global_preferences->reset();

View File

@ -14,7 +14,7 @@ void FactoryResetSwitch::write_state(bool state) {
this->publish_state(false);
if (state) {
ESP_LOGI(TAG, "Resetting to factory defaults...");
ESP_LOGI(TAG, "Resetting...");
// Let MQTT settle a bit
delay(100); // NOLINT
global_preferences->reset();

View File

@ -7,7 +7,7 @@ namespace gpio {
static const char *const TAG = "gpio.output";
void GPIOBinaryOutput::dump_config() {
ESP_LOGCONFIG(TAG, "GPIO Binary Output:");
ESP_LOGCONFIG(TAG, "Binary Output:");
LOG_PIN(" Pin: ", this->pin_);
LOG_BINARY_OUTPUT(this);
}

View File

@ -94,13 +94,13 @@ void ArduinoI2CBus::dump_config() {
break;
}
if (this->scan_) {
ESP_LOGI(TAG, "Results from i2c bus scan:");
ESP_LOGI(TAG, "Results from bus scan:");
if (scan_results_.empty()) {
ESP_LOGI(TAG, "Found no i2c devices!");
ESP_LOGI(TAG, "Found no devices");
} else {
for (const auto &s : scan_results_) {
if (s.second) {
ESP_LOGI(TAG, "Found i2c device at address 0x%02X", s.first);
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
} else {
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
}
@ -216,7 +216,7 @@ ErrorCode ArduinoI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cn
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
/// https://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf
void ArduinoI2CBus::recover_() {
ESP_LOGI(TAG, "Performing I2C bus recovery");
ESP_LOGI(TAG, "Performing bus recovery");
// For the upcoming operations, target for a 100kHz toggle frequency.
// This is the maximum frequency for I2C running in standard-mode.
@ -232,7 +232,7 @@ void ArduinoI2CBus::recover_() {
// line. In that case, the I2C bus cannot be recovered.
delayMicroseconds(half_period_usec);
if (digitalRead(scl_pin_) == LOW) { // NOLINT
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the I2C bus");
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the bus");
recovery_result_ = RECOVERY_FAILED_SCL_LOW;
return;
}

View File

@ -28,7 +28,7 @@ void IDFI2CBus::setup() {
#endif
if (port_ == I2C_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_HP_I2C_NUM);
ESP_LOGE(TAG, "No more than %u buses supported", SOC_HP_I2C_NUM);
this->mark_failed();
return;
}
@ -99,13 +99,13 @@ void IDFI2CBus::dump_config() {
break;
}
if (this->scan_) {
ESP_LOGI(TAG, "Results from i2c bus scan:");
ESP_LOGI(TAG, "Results from bus scan:");
if (scan_results_.empty()) {
ESP_LOGI(TAG, "Found no i2c devices!");
ESP_LOGI(TAG, "Found no devices");
} else {
for (const auto &s : scan_results_) {
if (s.second) {
ESP_LOGI(TAG, "Found i2c device at address 0x%02X", s.first);
ESP_LOGI(TAG, "Found device at address 0x%02X", s.first);
} else {
ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
}
@ -257,7 +257,7 @@ ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, b
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
/// https://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf
void IDFI2CBus::recover_() {
ESP_LOGI(TAG, "Performing I2C bus recovery");
ESP_LOGI(TAG, "Performing bus recovery");
const gpio_num_t scl_pin = static_cast<gpio_num_t>(scl_pin_);
const gpio_num_t sda_pin = static_cast<gpio_num_t>(sda_pin_);
@ -294,7 +294,7 @@ void IDFI2CBus::recover_() {
// with the SCL line. In that case, the I2C bus cannot be recovered.
delayMicroseconds(half_period_usec);
if (gpio_get_level(scl_pin) == 0) {
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the I2C bus");
ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the bus");
recovery_result_ = RECOVERY_FAILED_SCL_LOW;
return;
}

View File

@ -20,8 +20,7 @@ std::string build_json(const json_build_t &f) {
ESP_LOGV(TAG, "Attempting to allocate %zu bytes for JSON serialization", request_size);
DynamicJsonDocument json_document(request_size);
if (json_document.capacity() == 0) {
ESP_LOGE(TAG,
"Could not allocate memory for JSON document! Requested %zu bytes, largest free heap block: %zu bytes",
ESP_LOGE(TAG, "Could not allocate memory for document! Requested %zu bytes, largest free heap block: %zu bytes",
request_size, free_heap);
return "{}";
}
@ -29,7 +28,7 @@ std::string build_json(const json_build_t &f) {
f(root);
if (json_document.overflowed()) {
if (request_size == free_heap) {
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Overflowed largest free heap block: %zu bytes",
ESP_LOGE(TAG, "Could not allocate memory for document! Overflowed largest free heap block: %zu bytes",
free_heap);
return "{}";
}
@ -54,7 +53,7 @@ bool parse_json(const std::string &data, const json_parse_t &f) {
while (true) {
DynamicJsonDocument json_document(request_size);
if (json_document.capacity() == 0) {
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %zu bytes, free heap: %zu", request_size,
ESP_LOGE(TAG, "Could not allocate memory for document! Requested %zu bytes, free heap: %zu", request_size,
free_heap);
return false;
}
@ -74,7 +73,7 @@ bool parse_json(const std::string &data, const json_parse_t &f) {
request_size *= 2;
continue;
} else {
ESP_LOGE(TAG, "JSON parse error: %s", err.c_str());
ESP_LOGE(TAG, "Parse error: %s", err.c_str());
return false;
}
};

View File

@ -17,7 +17,7 @@ void MDNSComponent::setup() {
esp_err_t err = mdns_init();
if (err != ESP_OK) {
ESP_LOGW(TAG, "mDNS init failed: %s", esp_err_to_name(err));
ESP_LOGW(TAG, "Init failed: %s", esp_err_to_name(err));
this->mark_failed();
return;
}
@ -45,7 +45,7 @@ void MDNSComponent::setup() {
}
if (err != ESP_OK) {
ESP_LOGW(TAG, "Failed to register mDNS service %s: %s", service.service_type.c_str(), esp_err_to_name(err));
ESP_LOGW(TAG, "Failed to register service %s: %s", service.service_type.c_str(), esp_err_to_name(err));
}
}
}

View File

@ -13,7 +13,7 @@ void SafeModeButton::set_safe_mode(SafeModeComponent *safe_mode_component) {
}
void SafeModeButton::press_action() {
ESP_LOGI(TAG, "Restarting device in safe mode...");
ESP_LOGI(TAG, "Restarting in safe mode");
this->safe_mode_component_->set_safe_mode_pending(true);
// Let MQTT settle a bit

View File

@ -19,14 +19,13 @@ void SafeModeComponent::dump_config() {
ESP_LOGCONFIG(TAG, " Boot considered successful after %" PRIu32 " seconds",
this->safe_mode_boot_is_good_after_ / 1000); // because milliseconds
ESP_LOGCONFIG(TAG, " Invoke after %u boot attempts", this->safe_mode_num_attempts_);
ESP_LOGCONFIG(TAG, " Remain in safe mode for %" PRIu32 " seconds",
ESP_LOGCONFIG(TAG, " Remain for %" PRIu32 " seconds",
this->safe_mode_enable_time_ / 1000); // because milliseconds
if (this->safe_mode_rtc_value_ > 1 && this->safe_mode_rtc_value_ != SafeModeComponent::ENTER_SAFE_MODE_MAGIC) {
auto remaining_restarts = this->safe_mode_num_attempts_ - this->safe_mode_rtc_value_;
if (remaining_restarts) {
ESP_LOGW(TAG, "Last reset occurred too quickly; safe mode will be invoked in %" PRIu32 " restarts",
remaining_restarts);
ESP_LOGW(TAG, "Last reset occurred too quickly; will be invoked in %" PRIu32 " restarts", remaining_restarts);
} else {
ESP_LOGW(TAG, "SAFE MODE IS ACTIVE");
}
@ -48,7 +47,7 @@ void SafeModeComponent::set_safe_mode_pending(const bool &pending) {
uint32_t current_rtc = this->read_rtc_();
if (pending && current_rtc != SafeModeComponent::ENTER_SAFE_MODE_MAGIC) {
ESP_LOGI(TAG, "Device will enter safe mode on next boot");
ESP_LOGI(TAG, "Device will enter on next boot");
this->write_rtc_(SafeModeComponent::ENTER_SAFE_MODE_MAGIC);
}
@ -83,7 +82,7 @@ bool SafeModeComponent::should_enter_safe_mode(uint8_t num_attempts, uint32_t en
this->clean_rtc();
if (!is_manual_safe_mode) {
ESP_LOGE(TAG, "Boot loop detected. Proceeding to safe mode");
ESP_LOGE(TAG, "Boot loop detected. Proceeding");
}
this->status_set_error();

View File

@ -17,7 +17,7 @@ void SafeModeSwitch::write_state(bool state) {
this->publish_state(false);
if (state) {
ESP_LOGI(TAG, "Restarting device in safe mode...");
ESP_LOGI(TAG, "Restarting in safe mode");
this->safe_mode_component_->set_safe_mode_pending(true);
// Let MQTT settle a bit

View File

@ -11,7 +11,7 @@ void TemplateSelect::setup() {
return;
std::string value;
ESP_LOGD(TAG, "Setting up Template Select");
ESP_LOGD(TAG, "Setting up");
if (!this->restore_value_) {
value = this->initial_option_;
ESP_LOGD(TAG, "State from initial: %s", value.c_str());

View File

@ -58,7 +58,7 @@ void WiFiComponent::setup() {
}
void WiFiComponent::start() {
ESP_LOGCONFIG(TAG, "Starting WiFi...");
ESP_LOGCONFIG(TAG, "Starting");
ESP_LOGCONFIG(TAG, " Local MAC: %s", get_mac_address_pretty().c_str());
this->last_connected_ = millis();
@ -71,7 +71,7 @@ void WiFiComponent::start() {
SavedWifiSettings save{};
if (this->pref_.load(&save)) {
ESP_LOGD(TAG, "Loaded saved wifi settings: %s", save.ssid);
ESP_LOGD(TAG, "Loaded saved settings: %s", save.ssid);
WiFiAP sta{};
sta.set_ssid(save.ssid);
@ -160,7 +160,7 @@ void WiFiComponent::loop() {
case WIFI_COMPONENT_STATE_STA_CONNECTED: {
if (!this->is_connected()) {
ESP_LOGW(TAG, "WiFi Connection lost... Reconnecting...");
ESP_LOGW(TAG, "Connection lost; reconnecting");
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
this->retry_connect();
} else {
@ -201,7 +201,7 @@ void WiFiComponent::loop() {
if (!this->has_ap() && this->reboot_timeout_ != 0) {
if (now - this->last_connected_ > this->reboot_timeout_) {
ESP_LOGE(TAG, "Can't connect to WiFi, rebooting...");
ESP_LOGE(TAG, "Can't connect; rebooting");
App.reboot();
}
}
@ -310,7 +310,7 @@ void WiFiComponent::save_wifi_sta(const std::string &ssid, const std::string &pa
}
void WiFiComponent::start_connecting(const WiFiAP &ap, bool two) {
ESP_LOGI(TAG, "WiFi Connecting to '%s'...", ap.get_ssid().c_str());
ESP_LOGI(TAG, "Connecting to '%s'", ap.get_ssid().c_str());
#ifdef ESPHOME_LOG_HAS_VERBOSE
ESP_LOGV(TAG, "Connection Params:");
ESP_LOGV(TAG, " SSID: '%s'", ap.get_ssid().c_str());
@ -427,7 +427,7 @@ void WiFiComponent::print_connect_params_() {
ESP_LOGCONFIG(TAG, " Local MAC: %s", get_mac_address_pretty().c_str());
if (this->is_disabled()) {
ESP_LOGCONFIG(TAG, " WiFi is disabled!");
ESP_LOGCONFIG(TAG, " Disabled");
return;
}
ESP_LOGCONFIG(TAG, " SSID: " LOG_SECRET("'%s'"), wifi_ssid().c_str());
@ -459,7 +459,7 @@ void WiFiComponent::enable() {
if (this->state_ != WIFI_COMPONENT_STATE_DISABLED)
return;
ESP_LOGD(TAG, "Enabling WIFI...");
ESP_LOGD(TAG, "Enabling");
this->error_from_callback_ = false;
this->state_ = WIFI_COMPONENT_STATE_OFF;
this->start();
@ -469,7 +469,7 @@ void WiFiComponent::disable() {
if (this->state_ == WIFI_COMPONENT_STATE_DISABLED)
return;
ESP_LOGD(TAG, "Disabling WIFI...");
ESP_LOGD(TAG, "Disabling");
this->state_ = WIFI_COMPONENT_STATE_DISABLED;
this->wifi_disconnect_();
this->wifi_mode_(false, false);
@ -614,7 +614,7 @@ void WiFiComponent::check_connecting_finished() {
// We won't retry hidden networks unless a reconnect fails more than three times again
this->retry_hidden_ = false;
ESP_LOGI(TAG, "WiFi Connected!");
ESP_LOGI(TAG, "Connected");
this->print_connect_params_();
if (this->has_ap()) {
@ -644,7 +644,7 @@ void WiFiComponent::check_connecting_finished() {
uint32_t now = millis();
if (now - this->action_started_ > 30000) {
ESP_LOGW(TAG, "Timeout while connecting to WiFi.");
ESP_LOGW(TAG, "Connection timeout");
this->retry_connect();
return;
}
@ -660,18 +660,18 @@ void WiFiComponent::check_connecting_finished() {
}
if (status == WiFiSTAConnectStatus::ERROR_NETWORK_NOT_FOUND) {
ESP_LOGW(TAG, "WiFi network can not be found anymore.");
ESP_LOGW(TAG, "Network no longer found");
this->retry_connect();
return;
}
if (status == WiFiSTAConnectStatus::ERROR_CONNECT_FAILED) {
ESP_LOGW(TAG, "Connecting to WiFi network failed. Are the credentials wrong?");
ESP_LOGW(TAG, "Connection failed. Check credentials");
this->retry_connect();
return;
}
ESP_LOGW(TAG, "WiFi Unknown connection status %d", (int) status);
ESP_LOGW(TAG, "Unknown connection status %d", (int) status);
this->retry_connect();
}

View File

@ -91,7 +91,7 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
bool ret = WiFiClass::mode(set_mode);
if (!ret) {
ESP_LOGW(TAG, "Setting WiFi mode failed!");
ESP_LOGW(TAG, "Setting mode failed");
return false;
}

View File

@ -50,7 +50,7 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
bool ret = WiFi.mode(static_cast<wifi_mode_t>(mode));
if (!ret) {
ESP_LOGW(TAG, "Setting WiFi mode failed!");
ESP_LOGW(TAG, "Setting mode failed");
}
return ret;