Skip to content

Commit df0cb36

Browse files
ldabnashif
authored andcommitted
script: trim RTT log data on dictionary parser
The fact that log data captured with RTT has a header, like the following, impedes the parser to parse the data properly ``` Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. SEGGER J-Link V8.24 - Real time terminal output SEGGER J-Trace PRO V4.0, SN=XXXX Process: JLinkExe ``` Signed-off-by: Leonardo Bispo <[email protected]>
1 parent 298ea52 commit df0cb36

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/logging/dictionary/log_parser.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,19 @@ def read_log_file(args):
9696
sys.exit(1)
9797
logdata = logfile.read()
9898

99+
# RTT logs add header information to the logdata, the actual log comes
100+
# after newline following "Process:" line in logdata
101+
if b"Process:" in logdata:
102+
process_idx = logdata.find(b"Process:")
103+
newline_idx = logdata.find(b"\n", process_idx)
104+
if newline_idx != -1:
105+
# Keep only the data after this newline
106+
logdata = logdata[newline_idx + 1 :]
107+
logger.debug("Found 'Process:' in the RTT header, trimmed data")
108+
99109
return logdata
100110

111+
101112
def main():
102113
"""Main function of log parser"""
103114
args = parse_args()

0 commit comments

Comments
 (0)