|
| | Logger (uint32_t baud_rate) |
| |
| void | loop () override |
| |
| void | set_baud_rate (uint32_t baud_rate) |
| | Manually set the baud rate for serial, set to 0 to disable.
|
| |
| uint32_t | get_baud_rate () const |
| |
| Stream * | get_hw_serial () const |
| |
| uart_port_t | get_uart_num () const |
| |
| void | create_pthread_key () |
| |
| void | create_pthread_key () |
| |
| void | set_uart_selection (UARTSelection uart_selection) |
| |
| UARTSelection | get_uart () const |
| | Get the UART used by the logger.
|
| |
| void | set_log_level (uint8_t level) |
| | Set the default log level for this logger.
|
| |
| void | set_log_level (const char *tag, uint8_t log_level) |
| | Set the log level of the specified tag.
|
| |
| uint8_t | get_log_level () |
| |
| void | pre_setup () |
| | Set up this component.
|
| |
| void | dump_config () override |
| |
| uint8_t | level_for (const char *tag) |
| |
| void | add_log_callback (void *instance, void(*fn)(void *, uint8_t, const char *, const char *, size_t)) |
| | Register a log callback to receive log messages.
|
| |
| void | add_log_callback (void *instance, void(*fn)(void *, uint8_t, const char *, const char *, size_t)) |
| | No-op when log listeners are disabled.
|
| |
| void | add_level_listener (LoggerLevelListener *listener) |
| | Register a listener for log level changes.
|
| |
| float | get_setup_priority () const override |
| |
| void | log_vprintf_ (uint8_t level, const char *tag, int line, const char *format, va_list args) |
| |
| void | log_vprintf_ (uint8_t level, const char *tag, int line, const __FlashStringHelper *format, va_list args) |
| |
| virtual void | setup () |
| | Where the component's initialization should happen.
|
| |
| float | get_actual_setup_priority () const |
| |
| void | set_setup_priority (float priority) |
| |
| void | call () |
| |
| virtual void | on_shutdown () |
| |
| virtual void | on_safe_shutdown () |
| |
| virtual bool | teardown () |
| | Called during teardown to allow component to gracefully finish operations.
|
| |
| virtual void | on_powerdown () |
| | Called after teardown is complete to power down hardware.
|
| |
| uint8_t | get_component_state () const |
| |
| void | reset_to_construction_state () |
| | Reset this component back to the construction state to allow setup to run again.
|
| |
| bool | is_in_loop_state () const |
| | Check if this component has completed setup and is in the loop state.
|
| |
| bool | is_idle () const |
| | Check if this component is idle.
|
| |
| void | mark_failed () |
| | Mark this component as failed.
|
| |
| void | mark_failed (const LogString *message) |
| |
| void | disable_loop () |
| | Disable this component's loop.
|
| |
| void | enable_loop () |
| | Enable this component's loop.
|
| |
| void | enable_loop_soon_any_context () |
| | Thread and ISR-safe version of enable_loop() that can be called from any context.
|
| |
| bool | is_failed () const |
| |
| bool | is_ready () const |
| |
| virtual bool | can_proceed () |
| |
| bool | status_has_warning () const |
| |
| bool | status_has_error () const |
| |
| void | status_set_warning () |
| |
| void | status_set_warning (const char *message) |
| |
| void | status_set_warning (const LogString *message) |
| |
| void | status_set_error () |
| |
| void | status_set_error (const LogString *message) |
| |
| void | status_clear_warning () |
| |
| void | status_clear_error () |
| |
| void | status_momentary_warning (const char *name, uint32_t length=5000) |
| | Set warning status flag and automatically clear it after a timeout.
|
| |
| void | status_momentary_error (const char *name, uint32_t length=5000) |
| | Set error status flag and automatically clear it after a timeout.
|
| |
| bool | has_overridden_loop () const |
| |
| const LogString * | get_component_log_str () const ESPHOME_ALWAYS_INLINE |
| | Get the integration where this component was declared as a LogString for logging.
|
| |
| bool | should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out) |
| |
|
| void | log_vprintf_non_main_thread_ (uint8_t level, const char *tag, int line, const char *format, va_list args, const char *thread_name) |
| |
| void | cdc_loop_ () |
| |
| void | process_messages_ () |
| |
| void | write_msg_ (const char *msg, uint16_t len) |
| |
| void | write_msg_ (const char *msg, uint16_t len) |
| |
| void HOT | format_log_to_buffer_with_terminator_ (uint8_t level, const char *tag, int line, const char *format, va_list args, LogBuffer &buf, const char *thread_name) |
| |
| void HOT | format_log_to_buffer_with_terminator_P_ (uint8_t level, const char *tag, int line, const __FlashStringHelper *format, va_list args, LogBuffer &buf) |
| |
| void HOT | notify_listeners_ (uint8_t level, const char *tag, const LogBuffer &buf) |
| |
| void HOT | write_to_console_ (LogBuffer &buf) |
| |
| void HOT | write_log_buffer_to_console_ (LogBuffer &buf) |
| |
| template<typename FormatType > |
| void HOT | log_message_to_buffer_and_send_ (bool &recursion_guard, uint8_t level, const char *tag, int line, FormatType format, va_list args, const char *thread_name) |
| |
| void HOT | format_buffered_message_and_notify_ (uint8_t level, const char *tag, uint16_t line, const char *thread_name, const char *text, uint16_t text_length, LogBuffer &buf) |
| |
| const LogString * | get_uart_selection_ () |
| |
| void | dump_crash_ () |
| |
| const char * | get_thread_name_ (TaskHandle_t task) |
| |
| const char *HOT | get_thread_name_ () |
| |
| const char *HOT | get_thread_name_ (std::span< char > buff) |
| |
| const char *HOT | get_thread_name_ (std::span< char > buff, k_tid_t current_task=nullptr) |
| |
| bool HOT | is_non_main_task_recursive_ () const |
| |
| NonMainTaskRecursionGuard | make_non_main_task_guard_ () |
| |
| bool HOT | is_non_main_task_recursive_ () const |
| |
| RecursionGuard | make_non_main_task_guard_ () |
| |
| void | disable_loop_when_buffer_empty_ () |
| |
| friend | void::setup () |
| |
| friend | void::original_setup () |
| |
| void | set_component_source_ (uint8_t index) |
| | Set where this component was loaded from for some debug messages.
|
| |
| virtual void | call_setup () |
| |
| void | call_dump_config_ () |
| |
| void | enable_loop_slow_path_ () |
| |
| void | set_component_state_ (uint8_t state) |
| | Helper to set component state (clears state bits and sets new state)
|
| |
| bool | set_status_flag_ (uint8_t flag) |
| | Helper to set a status LED flag on both this component and the app.
|
| |
| void | set_interval (const char *name, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a const char* name.
|
| |
| void | set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a numeric ID (zero heap allocation).
|
| |
| void | set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f) |
| |
| void | set_interval (uint32_t interval, std::function< void()> &&f) |
| |
| bool | cancel_interval (const char *name) |
| | Cancel an interval function.
|
| |
| bool | cancel_interval (uint32_t id) |
| |
| bool | cancel_interval (InternalSchedulerID id) |
| |
| void | set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a const char* name.
|
| |
| void | set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a numeric ID (zero heap allocation).
|
| |
| void | set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f) |
| |
| void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
| |
| bool | cancel_timeout (const char *name) |
| | Cancel a timeout function.
|
| |
| bool | cancel_timeout (uint32_t id) |
| |
| bool | cancel_timeout (InternalSchedulerID id) |
| |
| void | defer (const char *name, std::function< void()> &&f) |
| | Defer a callback to the next loop() call with a const char* name.
|
| |
| void | defer (std::function< void()> &&f) |
| | Defer a callback to the next loop() call.
|
| |
| void | defer (uint32_t id, std::function< void()> &&f) |
| | Defer a callback with a numeric ID (zero heap allocation)
|
| |
| bool | cancel_defer (const char *name) |
| | Cancel a defer callback using the specified name, name must not be empty.
|
| |
| bool | cancel_defer (uint32_t id) |
| |
| void | status_clear_warning_slow_path_ () |
| |
| void | status_clear_error_slow_path_ () |
| |
Logger component for all ESPHome logging.
This class implements a multi-platform logging system with protection against recursion.
Recursion Protection Strategy:
- On ESP32: Uses task-specific recursion guards
- Main task: Uses a dedicated boolean member variable for efficiency
- Other tasks: Uses pthread TLS with a dynamically allocated key for task-specific state
- On other platforms: Uses a simple global recursion guard
We use pthread TLS via pthread_key_create to create a unique key for storing task-specific recursion state, which:
- Efficiently handles multiple tasks without locks or mutexes
- Works with ESP-IDF's pthread implementation that uses a linked list for TLS variables
- Avoids the limitations of the fixed FreeRTOS task local storage slots
Definition at line 144 of file logger.h.