ESPHome  2024.11.0
log.cpp
Go to the documentation of this file.
1 #include "log.h"
2 #include "defines.h"
3 #include "helpers.h"
4 
5 #ifdef USE_LOGGER
7 #endif
8 
9 namespace esphome {
10 
11 void HOT esp_log_printf_(int level, const char *tag, int line, const char *format, ...) { // NOLINT
12  va_list arg;
13  va_start(arg, format);
14  esp_log_vprintf_(level, tag, line, format, arg);
15  va_end(arg);
16 }
17 #ifdef USE_STORE_LOG_STR_IN_FLASH
18 void HOT esp_log_printf_(int level, const char *tag, int line, const __FlashStringHelper *format, ...) {
19  va_list arg;
20  va_start(arg, format);
21  esp_log_vprintf_(level, tag, line, format, arg);
22  va_end(arg);
23 }
24 #endif
25 
26 void HOT esp_log_vprintf_(int level, const char *tag, int line, const char *format, va_list args) { // NOLINT
27 #ifdef USE_LOGGER
28  auto *log = logger::global_logger;
29  if (log == nullptr)
30  return;
31 
32  log->log_vprintf_(level, tag, line, format, args);
33 #endif
34 }
35 
36 #ifdef USE_STORE_LOG_STR_IN_FLASH
37 void HOT esp_log_vprintf_(int level, const char *tag, int line, const __FlashStringHelper *format,
38  va_list args) { // NOLINT
39 #ifdef USE_LOGGER
40  auto *log = logger::global_logger;
41  if (log == nullptr)
42  return;
43 
44  log->log_vprintf_(level, tag, line, format, args);
45 #endif
46 }
47 #endif
48 
49 #if defined(USE_ESP32_FRAMEWORK_ARDUINO) || defined(USE_ESP_IDF)
50 int HOT esp_idf_log_vprintf_(const char *format, va_list args) { // NOLINT
51 #ifdef USE_LOGGER
52  auto *log = logger::global_logger;
53  if (log == nullptr)
54  return 0;
55 
56  log->log_vprintf_(ESPHOME_LOG_LEVEL, "esp-idf", 0, format, args);
57 #endif
58  return 0;
59 }
60 #endif
61 
62 } // namespace esphome
void log_vprintf_(int level, const char *tag, int line, const char *format, va_list args)
Definition: logger.cpp:61
Logger * global_logger
Definition: logger.cpp:198
void HOT esp_log_vprintf_(int level, const char *tag, int line, const char *format, va_list args)
Definition: log.cpp:26
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
int HOT esp_idf_log_vprintf_(const char *format, va_list args)
Definition: log.cpp:50