[logger] Replace std::function callbacks with LogListener interface (#12153)

This commit is contained in:
J. Nick Koston
2025-11-28 04:00:33 +00:00
committed by GitHub
parent 9bd148dfd1
commit 71dc402a30
12 changed files with 153 additions and 65 deletions
+15 -1
View File
@@ -7,6 +7,9 @@
#include "esphome/core/component.h"
#include "esphome/core/controller.h"
#include "esphome/core/entity_base.h"
#ifdef USE_LOGGER
#include "esphome/components/logger/logger.h"
#endif
#include <functional>
#include <list>
@@ -170,7 +173,14 @@ class DeferredUpdateEventSourceList : public std::list<DeferredUpdateEventSource
* under the '/light/...', '/sensor/...', ... URLs. A full documentation for this API
* can be found under https://esphome.io/web-api/index.html.
*/
class WebServer : public Controller, public Component, public AsyncWebHandler {
class WebServer : public Controller,
public Component,
public AsyncWebHandler
#ifdef USE_LOGGER
,
public logger::LogListener
#endif
{
#if !defined(USE_ESP32) && defined(USE_ARDUINO)
friend class DeferredUpdateEventSourceList;
#endif
@@ -230,6 +240,10 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
void dump_config() override;
#ifdef USE_LOGGER
void on_log(uint8_t level, const char *tag, const char *message, size_t message_len) override;
#endif
/// MQTT setup priority.
float get_setup_priority() const override;