ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
esphome::logger::LogCallback Struct Reference

Lightweight callback for receiving log messages without virtual dispatch overhead. More...

#include <logger.h>

Public Member Functions

void invoke (uint8_t level, const char *tag, const char *message, size_t message_len) const
 

Data Fields

void * instance
 
void(* fn )(void *, uint8_t, const char *, const char *, size_t)
 

Detailed Description

Lightweight callback for receiving log messages without virtual dispatch overhead.

Replaces the former LogListener virtual interface to eliminate per-implementer vtable sub-tables and thunk code (~39 bytes saved per class that used LogListener).

Usage: // In your component's setup(): if (logger::global_logger != nullptr) logger::global_logger->add_log_callback( this, [](void *self, uint8_t level, const char *tag, const char *message, size_t message_len) { static_cast<MyComponent *>(self)->on_log(level, tag, message, message_len); });

Definition at line 56 of file logger.h.

Member Function Documentation

◆ invoke()

void esphome::logger::LogCallback::invoke ( uint8_t level,
const char * tag,
const char * message,
size_t message_len ) const
inline

Definition at line 59 of file logger.h.

Field Documentation

◆ fn

void(* esphome::logger::LogCallback::fn) (void *, uint8_t, const char *, const char *, size_t)

Definition at line 58 of file logger.h.

◆ instance

void* esphome::logger::LogCallback::instance

Definition at line 57 of file logger.h.


The documentation for this struct was generated from the following file: