ESPHome  2024.11.0
logger_handler.cpp
Go to the documentation of this file.
1 #include "logger_handler.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace haier {
6 
7 void esphome_logger(haier_protocol::HaierLogLevel level, const char *tag, const char *message) {
8  switch (level) {
9  case haier_protocol::HaierLogLevel::LEVEL_ERROR:
10  esp_log_printf_(ESPHOME_LOG_LEVEL_ERROR, tag, __LINE__, "%s", message);
11  break;
12  case haier_protocol::HaierLogLevel::LEVEL_WARNING:
13  esp_log_printf_(ESPHOME_LOG_LEVEL_WARN, tag, __LINE__, "%s", message);
14  break;
15  case haier_protocol::HaierLogLevel::LEVEL_INFO:
16  esp_log_printf_(ESPHOME_LOG_LEVEL_INFO, tag, __LINE__, "%s", message);
17  break;
18  case haier_protocol::HaierLogLevel::LEVEL_DEBUG:
19  esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, "%s", message);
20  break;
21  case haier_protocol::HaierLogLevel::LEVEL_VERBOSE:
22  esp_log_printf_(ESPHOME_LOG_LEVEL_VERBOSE, tag, __LINE__, "%s", message);
23  break;
24  default:
25  // Just ignore everything else
26  break;
27  }
28 }
29 
30 void init_haier_protocol_logging() { haier_protocol::set_log_handler(esphome::haier::esphome_logger); };
31 
32 } // namespace haier
33 } // namespace esphome
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
Definition: log.cpp:11
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void esphome_logger(haier_protocol::HaierLogLevel level, const char *tag, const char *message)
void init_haier_protocol_logging()