Skip to content

Commit 4919a28

Browse files
committed
[refactoring][logging]: Normalize log output: always append a newline to echoed quote, switch to Serial1.print.
- EchoReceivedHandler: Always append a newline to the echoed quote before printing, ensuring each log entry has its own line, and making the log easily parseable. Moved peekConsume after print for clarity. - PrintHandler: Use Serial1.print instead of println, as log entries now include their own trailing newline. Signed-off-by: Goran Mišković <[email protected]>
1 parent 9b2d350 commit 4919a28

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/EchoReceivedHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ namespace e5 {
3333
if (available == 0) return;
3434
const char *data = m_io.peekBuffer();
3535
// Print any incoming echo data
36-
std::string chunk(data, available);
37-
m_io.peekConsume(available);
38-
auto quote = std::make_unique<std::string>(chunk);
36+
auto quote = std::make_unique<std::string>(data);
37+
quote->push_back('\n');
3938
m_serial_printer.print(std::move(quote));
39+
m_io.peekConsume(available);
4040
}
4141

4242
} // namespace e5

src/PrintHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace e5 {
3131
*/
3232
void PrintHandler::onWork() {
3333
if (!m_message->empty()) {
34-
Serial1.println(m_message->c_str());
34+
Serial1.print(m_message->c_str());
3535
}
3636
}
3737

0 commit comments

Comments
 (0)