ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
logger_rp2.cpp
Go to the documentation of this file.
1#ifdef USE_RP2
2#include "logger.h"
4#ifdef USE_RP2_CRASH_HANDLER
6#endif
7#include "esphome/core/log.h"
8
9namespace esphome::logger {
10
11ESPHOME_LOG_TAG(TAG, "logger");
12
13void Logger::pre_setup() {
14 if (this->baud_rate_ > 0) {
15 switch (this->uart_) {
17 this->hw_serial_ = &Serial1;
18 Serial1.begin(this->baud_rate_);
19 break;
21 this->hw_serial_ = &Serial2;
22 Serial2.begin(this->baud_rate_);
23 break;
25 this->hw_serial_ = &Serial;
26 Serial.begin(this->baud_rate_);
27 break;
28 }
29 }
30 global_logger = this;
31 ESP_LOGI(TAG, "Log initialized");
32#ifdef USE_RP2_CRASH_HANDLER
34#endif
35}
36
37const LogString *Logger::get_uart_selection_() {
38 switch (this->uart_) {
40 return LOG_STR("UART0");
42 return LOG_STR("UART1");
43#ifdef USE_LOGGER_USB_CDC
45 return LOG_STR("USB_CDC");
46#endif
47 default:
48 return LOG_STR("UNKNOWN");
49 }
50}
51
52#ifdef USE_CRASH_HANDLER
55#endif
56
57} // namespace esphome::logger
58#endif // USE_RP2
UARTSelection uart_
Definition logger.h:362
const LogString * get_uart_selection_()
void pre_setup()
Set up this component.
bool crash_log_pending()
Whether a crash record from before this boot is waiting to be reported.
@ UART_SELECTION_USB_CDC
Definition logger.h:121
@ UART_SELECTION_UART0
Definition logger.h:112
@ UART_SELECTION_UART1
Definition logger.h:116
Logger * global_logger
Definition logger.cpp:276
void log_crash_to_client()
Log the previous crash for a client that just subscribed to the logs.
ESPHOME_LOG_TAG(TAG, "logger")
bool crash_handler_has_data()
Returns true if crash data was found this boot, reading it first if needed.
void crash_handler_log()
Log crash data if a crash was detected on previous boot.