mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 15:35:59 -07:00
[mqtt] Avoid heap allocations when logging IP addresses (#12686)
This commit is contained in:
@@ -153,13 +153,14 @@ void MQTTClientComponent::on_log(uint8_t level, const char *tag, const char *mes
|
||||
#endif
|
||||
|
||||
void MQTTClientComponent::dump_config() {
|
||||
char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"MQTT:\n"
|
||||
" Server Address: %s:%u (%s)\n"
|
||||
" Username: " LOG_SECRET("'%s'") "\n"
|
||||
" Client ID: " LOG_SECRET("'%s'") "\n"
|
||||
" Clean Session: %s",
|
||||
this->credentials_.address.c_str(), this->credentials_.port, this->ip_.str().c_str(),
|
||||
this->credentials_.address.c_str(), this->credentials_.port, this->ip_.str_to(ip_buf),
|
||||
this->credentials_.username.c_str(), this->credentials_.client_id.c_str(),
|
||||
YESNO(this->credentials_.clean_session));
|
||||
if (this->is_discovery_ip_enabled()) {
|
||||
@@ -246,7 +247,8 @@ void MQTTClientComponent::check_dnslookup_() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Resolved broker IP address to %s", this->ip_.str().c_str());
|
||||
char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
|
||||
ESP_LOGD(TAG, "Resolved broker IP address to %s", this->ip_.str_to(ip_buf));
|
||||
this->start_connect_();
|
||||
}
|
||||
#if defined(USE_ESP8266) && LWIP_VERSION_MAJOR == 1
|
||||
|
||||
Reference in New Issue
Block a user