Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ESC" Character in test.log when viewed in Sublime

Whenever I open up test.log from any rails application I get the following screenshot in Sublime. I've tried messing around with encodings, but couldn't find anything that fixed it.

enter image description here

Any ideas on what is going on?

like image 489
Noah Clark Avatar asked Aug 31 '12 20:08

Noah Clark


3 Answers

These are control characters used to add colour to the log files. Sublime text apparently doesn't support this.

If you're mostly going to be viewing log files with editors that don't understand these colour codes you can turn this off with the rails config.colorize_logging setting

like image 105
Frederick Cheung Avatar answered Nov 20 '22 00:11

Frederick Cheung


There's a Sublime package to turn these ANSI/vt100 escape sequences into colored text -- SublimeANSI (use Package Control and look for ANSIescape) -- this adds an "ANSI" file type that will display your log file in glorious color. (The file is displayed read-only but you can change the type back to "Plain Text" if you want to edit it.)

like image 38
Tom Hundt Avatar answered Nov 20 '22 02:11

Tom Hundt


Backing up Tom Hundt's answer... SublimeANSI is the way to go. Compare these before/after shots:

Sublime's default rendering of colorized Rails log output:

Sublime's default rendering of colorized Rails log output

Now change the syntax highlighting to ANSI:

Now change the syntax highlighting to ANSI

Now, marvel in the majesty of SumblimeANSI's rendering:

enter image description here

Learn more about SublimeANSI package at: https://github.com/aziz/SublimeANSI

Note: To install it in Package Manager, search for "ANSIescape" ... NOT "SublimeANSI". This confused me for a hot minute.

like image 1
David Hempy Avatar answered Nov 20 '22 00:11

David Hempy