gvalkov / tailon

Webapp for looking at and searching through files and streams
Apache License 2.0
312 stars 56 forks source link

Support terminal escape codes for colors #14

Open deseven opened 5 years ago

deseven commented 5 years ago

There are some escape sequences for terminals, usually used for color output. Many loggers love to use them.

As an example: some text

As a bare minimum, if you don't want to make color support, it would be nice to at least know about it and strip them from text completely.

paladine commented 4 years ago

+1 to this. I wouldn't mind doing this myself as I have a fully functional ANSI parser in both C/Java, but I'd have to port to go and web frontend development isn't my forte. If somebody could point me in the right direction, I'd be happy to contribute.

NickWaterton commented 4 years ago

I just implemented this in the Python version of tailon. I’m using a rewritten version of grc (grcat) to insert ANSI codes, and ansi2html to convert to inline html.

The only slight issue is in the logfile.js file, you have to remove the escapeHtml filter, otherwise the inline html prints as plain text instead of being rendered. This also means that any inline html you try to view will also be rendered. I haven’t had too much problem with this, as most log files don’t have inline html in them.