IRNAS / irnas-east-software

East is a command line meta-tool, useful for creating, managing, and deploying Zephyr or nRF Connect SDK projects.
MIT License
10 stars 1 forks source link

BUG - `east util rtt -l` does not clear ANSI escape sequences #105

Closed TjazVracko closed 10 months ago

TjazVracko commented 10 months ago

Describe the bug

When using the log file option (or append) for east util rtt the text has space sequences in it (since the terminal output I am viewing has color codes and is a shell).

Example log file:

rtt:~$ [00:00:00.475,769] <inf> lr11xx_board: Event trigger set in global thread.
rtt:~$ [00:00:00.486,602] <inf> mflt: Reset Reason, RESETREAS=0x10000
rtt:~$ [00:00:00.486,633] <inf> mflt: Reset Causes: 
rtt:~$ [00:00:00.486,694] <inf> mflt:  Software
rtt:~$ [00:00:00.487,518] <inf> mflt: GNU Build ID: b2b06e4543b60af58af8990a8956c5e6a8d62fff
rtt:~$ [00:00:00.488,189] <inf> version_info: ---------------------------------------------
rtt:~$ [00:00:00.488,220] <inf> version_info: App version:  1.0.0
rtt:~$ [00:00:00.488,250] <inf> version_info: Git describe:     v1.0.0-2-g1f56cd3
rtt:~$ [00:00:00.488,281] <inf> version_info: Git hash:     1f56cd3
rtt:~$ [00:00:00.488,342] <inf> version_info: Git dirty:    no
rtt:~$ [00:00:00.488,372] <inf> version_info: Build type:   dev
rtt:~$ [00:00:00.488,433] <inf> version_info: NCS:      2.2.0

But It should look like this:

rtt:~$ [00:00:00.475,769] <inf> lr11xx_board: Event trigger set in global thread.
rtt:~$ [00:00:00.486,602] <inf> mflt: Reset Reason, RESETREAS=0x10000
rtt:~$ [00:00:00.486,633] <inf> mflt: Reset Causes: 
rtt:~$ [00:00:00.486,694] <inf> mflt:  Software
rtt:~$ [00:00:00.487,518] <inf> mflt: GNU Build ID: b2b06e4543b60af58af8990a8956c5e6a8d62fff
rtt:~$ [00:00:00.488,189] <inf> version_info: ---------------------------------------------
rtt:~$ [00:00:00.488,220] <inf> version_info: App version:   1.0.0
rtt:~$ [00:00:00.488,250] <inf> version_info: Git describe:  v1.0.0-2-g1f56cd3
rtt:~$ [00:00:00.488,281] <inf> version_info: Git hash:  1f56cd3
rtt:~$ [00:00:00.488,342] <inf> version_info: Git dirty:     no
rtt:~$ [00:00:00.488,372] <inf> version_info: Build type:    dev
rtt:~$ [00:00:00.488,433] <inf> version_info: NCS:       2.2.0

Firmware/Software Version 0.17.3

Hardware Version /

To Reproduce

Build some project with RTT shell and logging via shell. You will see there are escape codes on each line.

Additional context

Some useful links: https://stackoverflow.com/questions/17998978/removing-colors-from-output https://superuser.com/questions/380772/removing-ansi-color-codes-from-text-stream https://unix.stackexchange.com/questions/111899/how-to-strip-color-codes-out-of-stdout-and-pipe-to-file-and-stdout

TjazVracko commented 10 months ago

https://pypi.org/project/ansi2txt/