HardFOC Core
API reference
Loading...
Searching...
No Matches
EspLoggerFactory.cpp File Reference

ESP32-family implementation of Logger::CreateDefaultBaseLogger(). More...

#include "../Logger.h"
#include "../../../hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseLogger.h"
#include "../../../hf-core-drivers/internal/hf-internal-interface-wrap/inc/mcu/esp32/EspLogger.h"
#include <memory>

Detailed Description

ESP32-family implementation of Logger::CreateDefaultBaseLogger().

The Logger handler (handlers/logger/Logger.cpp) is intentionally MCU-agnostic — it only knows about the abstract BaseLogger interface. Each platform contributes a small factory translation unit that knows which concrete backend to instantiate. This keeps EspLogger.h / esp_log.h (and any future MCU-specific backend headers) out of the shared handler implementation.

Linking is handled by cmake/hf_core_build_settings.cmake: when HF_CORE_ENABLE_LOGGER=ON and the target MCU family is ESP32, this file is added to HF_CORE_HANDLER_SOURCES. Other MCU families ship their own <Mcu>LoggerFactory.cpp (e.g. StmLoggerFactory.cpp for STM32 — STM32 backend is currently a stub).

If you want the logger to ride on a different ESP32 transport at runtime (e.g. EspUsbSerialJtag instead of UART0 EspLogger), don't edit this file — call the explicit injection overload from the HAL instead:

std::make_unique<MyUsbSerialJtagBackedLogger>(...)
);
static Logger & GetInstance() noexcept
Get singleton instance.
Definition Logger.cpp:91
bool Initialize(const LogConfig &config=LogConfig{}) noexcept
Initialize the logger using the platform-default BaseLogger backend (resolved via the MCU-specific lo...
Definition Logger.cpp:100
Logging configuration.
Definition Logger.h:96
Author
HardFOC Team
Date
2026