From 39c42bdd1334734a8fd71f13b824189704c2f714 Mon Sep 17 00:00:00 2001 From: Abasz <32517724+Abasz@users.noreply.github.com> Date: Sun, 6 Jul 2025 21:17:25 +0000 Subject: [PATCH 1/2] Fix platformio-basic example Fix the `printTimestamp` and `printCarret` call signature to match `printfunction` typedef. --- examples/platformio-basic/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platformio-basic/src/main.cpp b/examples/platformio-basic/src/main.cpp index 0a87923..b4e6338 100644 --- a/examples/platformio-basic/src/main.cpp +++ b/examples/platformio-basic/src/main.cpp @@ -23,13 +23,13 @@ String stringValue1 = "this is a string"; float floatValue; double doubleValue; -void printTimestamp(Print *_logOutput) { +void printTimestamp(Print *_logOutput, int) { char c[12]; int m = sprintf(c, "%10lu ", millis()); _logOutput->print(c); } -void printCarret(Print *_logOutput) { _logOutput->print('>'); } +void printCarret(Print *_logOutput, int) { _logOutput->print('>'); } void setup() { // Set up serial port and wait until connected From 9e2e4375538a6c5accab65c180c72012dc804302 Mon Sep 17 00:00:00 2001 From: Abasz <32517724+Abasz@users.noreply.github.com> Date: Sun, 6 Jul 2025 21:28:36 +0000 Subject: [PATCH 2/2] Fix linker error when compiling with optimization Move writeLog definition into the header file. Fixes #9. (https://github.com/JSC-TechMinds/Arduino-Log/issues/9) --- src/ArduinoLog.cpp | 10 ---------- src/ArduinoLog.h | 10 +++++++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ArduinoLog.cpp b/src/ArduinoLog.cpp index d2f27a0..b9e3a82 100644 --- a/src/ArduinoLog.cpp +++ b/src/ArduinoLog.cpp @@ -279,16 +279,6 @@ void Logging::printFormat(const char format, va_list *args) { #endif } -#ifndef DISABLE_LOGGING -template void Logging::writeLog(Args... args) { - for (int i = 0; i < _handlerCount; i++) { - if (_logOutputs[i]) { - _logOutputs[i]->print(args...); - } - } -} -#endif - #ifndef __DO_NOT_INSTANTIATE__ Logging Log = Logging(); #endif diff --git a/src/ArduinoLog.h b/src/ArduinoLog.h index 71b82e1..2d1e949 100644 --- a/src/ArduinoLog.h +++ b/src/ArduinoLog.h @@ -450,7 +450,15 @@ class Logging { Print* _logOutputs[LOG_MAX_HANDLERS]; int _handlerCount; - template void writeLog(Args... args); +#ifndef DISABLE_LOGGING + template void writeLog(Args... args) { + for (int i = 0; i < _handlerCount; i++) { + if (_logOutputs[i]) { + _logOutputs[i]->print(args...); + } + } + } +#endif #ifdef ESP32 SemaphoreHandle_t _semaphore; #endif