Ask Your Question
0

Unexpected heading and trailing symbols in logfile's string

asked 2015-03-10 07:28:16 -0600

Ilya S. gravatar image

Hi all! I'm using Indigo on Ubuntu 14.04 and facing strange issue with redirecting node logging to the file. When specific node's output in roslaunch XML-file is set to "log" some unexpended symbols are added to the head and to the tail of each log string. Log string looks like as follows .[0m<string>.[0m where <string> - is the string which is intended to be put in file and "." stands for the symbol with code "1B" in hex. When output is set to "screen" no extra symbols is shown. I'm wondering why are these symbols appended to the string in log file and is there any chance to get rid of the?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-03-10 08:00:15 -0600

gvdhoorn gravatar image

updated 2015-03-10 08:03:06 -0600

I'm wondering why are these symbols appended to the string in log file [..]

They are ANSI escape codes, used by ROS logging to add colours and font weights (such as boldface) to logging lines.

When output is set to "screen" no extra symbols is shown.

That is because the terminal driver knows how to interprete these sequences and uses them to set font properties for the logging lines.

is there any chance to get rid of the(m)?

If you just want to view a file with embedded escape sequences, you can use less -r /path/to/your/file.log. less will interprete the escape codes then and show you the text as it was printed to the console.

To actually remove them from the file seems to be not so straightforward (see here).

Some options however:

edit flag offensive delete link more

Comments

Thank you very much for your prompt and such a detailed answer!

Ilya S. gravatar imageIlya S. ( 2015-03-10 08:49:47 -0600 )edit

No problem.

Also: please don't use answers to post comments, use the add comment button for that.

gvdhoorn gravatar imagegvdhoorn ( 2015-03-10 09:22:58 -0600 )edit

Ok. Got it!

Ilya S. gravatar imageIlya S. ( 2015-03-10 10:11:07 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-10 07:28:16 -0600

Seen: 318 times

Last updated: Mar 10 '15