FastLED 3.10.6
Loading...
Searching...
No Matches

◆ flush()

void fl::AsyncLogger::flush ( )

Definition at line 69 of file async_logger.cpp.hpp.

69 {
70 const char* msg;
71 fl::u16 len;
72
73 // 256-byte stack buffer - handles most messages in a single chunk
74 // Avoids heap allocation entirely by chunking long messages
75 char buffer[256];
76
77 while (mQueue.tryPop(&msg, &len)) {
78 fl::u16 offset = 0;
79
80 // Process message in chunks to avoid heap allocation
81 while (offset < len) {
82 fl::u16 chunk_size = min(len - offset, static_cast<fl::u16>(sizeof(buffer) - 1));
83 fl::memcpy(buffer, msg + offset, chunk_size);
84 buffer[chunk_size] = '\0'; // Null-terminate
85
86 offset += chunk_size;
87
88 if (offset >= len) {
89 // Last chunk or whole message - use println (adds newline)
90 fl::println(buffer);
91 } else {
92 // Not last chunk - use print (no newline)
93 fl::print(buffer);
94 }
95 }
96
97 mQueue.commit();
98 }
99}
AsyncLogQueue< 128, 4096 > mQueue
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
void print(const char *str)
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Definition math.h:71
void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
void println(const char *str) FL_NO_EXCEPT

References fl::memcpy(), fl::min(), mQueue, offset(), fl::print(), and fl::println().

Referenced by ~AsyncLogger().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: