This commit is contained in:
J. Nick Koston
2026-02-04 05:50:41 +01:00
parent 068fc3476b
commit a5869c2a9c
8 changed files with 210 additions and 246 deletions
+3 -5
View File
@@ -118,9 +118,7 @@ void Logger::pre_setup() {
ESP_LOGI(TAG, "Log initialized");
}
void HOT Logger::write_msg_(const char *msg, size_t len) {
// Length is now always passed explicitly - no strlen() fallback needed
void HOT Logger::write_msg_(const LogBuffer &buf) {
#if defined(USE_LOGGER_UART_SELECTION_USB_CDC) || defined(USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG)
// USB CDC/JTAG - single write including newline (already in buffer)
// Use fwrite to stdout which goes through VFS to USB console
@@ -130,10 +128,10 @@ void HOT Logger::write_msg_(const char *msg, size_t len) {
// This is compile-time selection, not runtime detection - if USB is configured, it's always used.
// There is no fallback to regular UART if "USB isn't connected" - that's the user's responsibility
// to configure correctly for their hardware. This approach eliminates runtime overhead.
fwrite(msg, 1, len, stdout);
fwrite(buf.data, 1, buf.pos, stdout);
#else
// Regular UART - single write including newline (already in buffer)
uart_write_bytes(this->uart_num_, msg, len);
uart_write_bytes(this->uart_num_, buf.data, buf.pos);
#endif
}