Reputation: 23280
I have some log files that use color schemes. I would like to be able to view those logs in Sublime Text and still see the colors. Currently when I view the log file I see things like this:
2013-11-20T15:53:02.711Z - [34minfo[39m: Default profiles created
2013-11-20T15:53:02.712Z - [34minfo[39m: Finished server initialization
2013-11-20T15:53:02.712Z - [34minfo[39m: Start collecting garbage
The text between [34m and [39m is colored. Is anyone aware of a plugin that does this?
Upvotes: 45
Views: 21111
Reputation: 52767
@keheliya's answer is correct...but how to install said package?
To install any other package, you need the Package Control package. Follow the installation instructions here: https://packagecontrol.io/installation
In short:
Open the command palette
Win/Linux: ctrl+shift+p, Mac: cmd+shift+p
Type
Install Package Control
, press enter
Or, using the Menu:
- Open the
Tools
menu- Select
Install Package Control…
Now, to use it, click the current syntax highlighting text in the very bottom right of your Sublime Text 3 window. Choose "ANSI", as shown below.
You may also choose this from the menus: View --> Syntax --> ANSI.
Instead of Sublime Text 3, you can also try less -r filename
and less -R filename
, but if your file has mixed color codes it may be easier to look at in Sublime Text 3 anyway. My favorite less
command options are -RFX
, which produce the effect seen in git diff
(and also seen in my thin wrapper program I wrote to show line numbers in git diff
: git diffn
). For example:
less -RFX filename
Description:
-R
to interpret ANSI color codes-F
to quit immediately if the output takes up less than one-screen, and:-X
to not clear the screen when less exits!See:
Upvotes: 40
Reputation: 2553
Install the SublimeANSI plugin and change the syntax of your log file to ANSI
(using the View
-> Syntax
menu.)
Also available as ANSIescape on Package Control.
Upvotes: 48
Reputation: 102862
PersistentRegexHighlight
should be able to do what you're looking for. I'm no regex guru, so I'm not sure exactly how you'd set them up, but you could make regexes that match [34m
at the beginning and [39m
at the end, and highlight the middle with a blue scope.
Unfortunately, you won't be able to hide the color codes themselves, but this should at least help.
Upvotes: 1