LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-12-2008, 10:49 PM   #1
ideasman
LQ Newbie
 
Registered: Mar 2004
Location: Australia
Distribution: Home brew
Posts: 25

Rep: Reputation: 15
Converting colored logs to HTML


Hi, Im running a build bot that generates colored output to the console using console escape sequences (ECMA-48 Im told), when these logs are redirected to a file they are ofcourse not colored, the text looks like this...

Code:
header_script.c:165: warning: unused variable ‘script’
in python the strings colors are defined like this
Code:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
They print in color in xterm fine.

Id like to convert this to a more usable format (probably HTML) but could not find any apps that does this.

There's a script here that is supposed to but it dosnt replace any characters in my file.

http://www.pixelbeat.org/docs/terminal_colours/
http://www.pixelbeat.org/docs/termin...v/ansi2html.sh
 
Old 11-13-2008, 06:16 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Crdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Quote:
Originally Posted by ideasman View Post
Hi, Im running a build bot that generates colored output to the console using console escape sequences (ECMA-48 Im told), when these logs are redirected to a file they are ofcourse not colored, the text looks like this...

Code:
header_script.c:165: warning: unused variable €˜script€™
The problem is how to get an usable output. If there's no way to get a clean output for color codes, then at most you can design something to parse the log files, search for those strings and substitute them with usable color codes (might it be html tags, might it be ANSI codes to display it under a shell).

For example, if you store the log line you posted into a file called "test", then this should print it using colors:

Code:
echo -e $(cat test | sed -e 's/€˜/\\033[95m/' -e 's/€™/\\033[0m/')
You would need to design a sed script for all the colors I guess, but it should be quite trivial. The same trick should work for html tags if that's what you want.

I guess this script changes ANSI to HTML, but whatever the output of your bot is, it is not ANSI compatible. So, you need to design your own parser. It should be quite trivial in either python or bash/sed, but I think that the best option would be to modify the original bot to use an ANSI compatible output. That would eliminate the need for any external stuff, and it should be easily doable.
 
  


Reply

Tags
character, color, log, terminal


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting DOC to HTML using PHP Xing Programming 3 02-17-2009 06:32 AM
converting html to text ikinnu Linux - Software 3 07-31-2008 01:50 AM
Converting pdf to Html linuxeagle Linux - General 1 04-23-2004 08:03 AM
Converting html files to pdf saurya_s Linux - Software 1 01-12-2004 06:49 AM
Converting Text To HTML Glock Shooter Programming 6 07-03-2002 06:08 PM


All times are GMT -5. The time now is 11:42 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration