mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Skip API log message calls for unsubscribed log levels (#9514)
This commit is contained in:
		| @@ -1404,9 +1404,6 @@ void APIConnection::update_command(const UpdateCommandRequest &msg) { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| bool APIConnection::try_send_log_message(int level, const char *tag, const char *line, size_t message_len) { | bool APIConnection::try_send_log_message(int level, const char *tag, const char *line, size_t message_len) { | ||||||
|   if (this->flags_.log_subscription < level) |  | ||||||
|     return false; |  | ||||||
|  |  | ||||||
|   // Pre-calculate message size to avoid reallocations |   // Pre-calculate message size to avoid reallocations | ||||||
|   uint32_t msg_size = 0; |   uint32_t msg_size = 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -209,6 +209,7 @@ class APIConnection : public APIServerConnection { | |||||||
|     return static_cast<ConnectionState>(this->flags_.connection_state) == ConnectionState::CONNECTED || |     return static_cast<ConnectionState>(this->flags_.connection_state) == ConnectionState::CONNECTED || | ||||||
|            this->is_authenticated(); |            this->is_authenticated(); | ||||||
|   } |   } | ||||||
|  |   uint8_t get_log_subscription_level() const { return this->flags_.log_subscription; } | ||||||
|   void on_fatal_error() override; |   void on_fatal_error() override; | ||||||
|   void on_unauthenticated_access() override; |   void on_unauthenticated_access() override; | ||||||
|   void on_no_setup_connection() override; |   void on_no_setup_connection() override; | ||||||
|   | |||||||
| @@ -104,7 +104,7 @@ void APIServer::setup() { | |||||||
|             return; |             return; | ||||||
|           } |           } | ||||||
|           for (auto &c : this->clients_) { |           for (auto &c : this->clients_) { | ||||||
|             if (!c->flags_.remove) |             if (!c->flags_.remove && c->get_log_subscription_level() >= level) | ||||||
|               c->try_send_log_message(level, tag, message, message_len); |               c->try_send_log_message(level, tag, message, message_len); | ||||||
|           } |           } | ||||||
|         }); |         }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user