Skip to content

Commit 49834c1

Browse files
logging: fix accidental tailing \r\n on certain SerialLoggingReporter messages
`SerialLoggingReporter._create_message()` appends the representations for `\r\n` to each log message unconditionally. But `\r\n` must only be appended when splitting serial input on `\r\n` in `SerialLoggingReporter.notify()`. Fix that by appending actual `\r\n` to the data to be logged. Do that before its representation is generated. A future commit can then add that data to the `extra` data in the log message allowing reconstruction of the serial data sent/received from the logs. Signed-off-by: Bastian Krause <bst@pengutronix.de>
1 parent be8f3a2 commit 49834c1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

labgrid/logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def vt100_replace_cr_nl(self, buf):
7878
return string
7979

8080
def _create_message(self, event, data):
81-
return "{source} {dirind} {data}␍␤".format(
81+
return "{source} {dirind} {data}".format(
8282
source=event.step.source,
8383
dirind="<" if event.step.title == "read" else ">",
8484
data=data,
@@ -105,6 +105,7 @@ def notify(self, event):
105105
self.lastevent = event
106106

107107
for part in parts:
108+
part += b"\r\n"
108109
data = self.vt100_replace_cr_nl(part)
109110
logger.log(logging.CONSOLE, self._create_message(event, data), extra=extra)
110111

0 commit comments

Comments
 (0)