ESPHome
2024.11.1
esphome
esphome
components
logger
logger_esp8266.cpp
Go to the documentation of this file.
1
#ifdef USE_ESP8266
2
#include "
logger.h
"
3
#include "
esphome/core/log.h
"
4
5
namespace
esphome
{
6
namespace
logger {
7
8
static
const
char
*
const
TAG =
"logger"
;
9
10
void
Logger::pre_setup
() {
11
if
(this->
baud_rate_
> 0) {
12
switch
(this->
uart_
) {
13
case
UART_SELECTION_UART0
:
14
case
UART_SELECTION_UART0_SWAP
:
15
this->
hw_serial_
= &Serial;
16
Serial.begin(this->
baud_rate_
);
17
if
(this->
uart_
==
UART_SELECTION_UART0_SWAP
) {
18
Serial.swap();
19
}
20
Serial.setDebugOutput(ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE);
21
break
;
22
case
UART_SELECTION_UART1
:
23
this->
hw_serial_
= &Serial1;
24
Serial1.begin(this->
baud_rate_
);
25
Serial1.setDebugOutput(ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE);
26
break
;
27
}
28
}
else
{
29
uart_set_debug(UART_NO);
30
}
31
32
global_logger
=
this
;
33
34
ESP_LOGI(TAG,
"Log initialized"
);
35
}
36
37
void
HOT
Logger::write_msg_
(
const
char
*msg) { this->
hw_serial_
->println(msg); }
38
39
const
char
*
const
UART_SELECTIONS
[] = {
"UART0"
,
"UART1"
,
"UART0_SWAP"
};
40
41
const
char
*
Logger::get_uart_selection_
() {
return
UART_SELECTIONS[this->
uart_
]; }
42
43
}
// namespace logger
44
}
// namespace esphome
45
#endif
esphome::logger::Logger::hw_serial_
Stream * hw_serial_
Definition:
logger.h:157
esphome::logger::UART_SELECTION_UART1
Definition:
logger.h:40
esphome::logger::global_logger
Logger * global_logger
Definition:
logger.cpp:198
esphome::logger::UART_SELECTION_UART0_SWAP
Definition:
logger.h:51
esphome::logger::UART_SELECTION_UART0
Definition:
logger.h:36
esphome::logger::Logger::get_uart_selection_
const char * get_uart_selection_()
Definition:
logger_esp32.cpp:210
esphome::logger::Logger::uart_
UARTSelection uart_
Definition:
logger.h:151
esphome::logger::Logger::pre_setup
void pre_setup()
Set up this component.
Definition:
logger_esp32.cpp:97
logger.h
esphome::logger::UART_SELECTIONS
const char *const UART_SELECTIONS[]
Definition:
logger_esp32.cpp:197
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::logger::Logger::write_msg_
void write_msg_(const char *msg)
Definition:
logger_esp32.cpp:175
log.h
esphome::logger::Logger::baud_rate_
uint32_t baud_rate_
Definition:
logger.h:146
Generated by
1.8.13