4

I have some log files that are hard to read without coloring:

05-04-2014 19:04:17 < [email protected]: this is what I say
05-04-2014 19:04:18 < [email protected]: something else
07-06-2014 17:45:34 < andre!andre@shellhost/milliways: nslookup: can't resolve this ... 

Is there a way to watch this log file with colored usernames and without the domain (in this example without "@something.net")?

4
  • 1
    Without the domain = anotheruser!~user instead of [email protected]?
    – unor
    Apr 6, 2014 at 5:37
  • 1
    probably only the nick: anotheruser. I suggest writing it yourself with some scripting language, parse it with regexp and output HTML. Apr 6, 2014 at 10:14
  • I know moinmoin wiki, and pastebin.org do the syntax highlighing. Pygments will do it (though I haven't used it myself, it is very popular) Jun 10, 2014 at 15:05
  • Not sure what you mean though "without the domain" Jun 10, 2014 at 15:06

2 Answers 2

3

I use ccze to colorize my logs, not chatlogs though. I'm uncertain if there is a plugin for chats already present (counldn't find one at first search) but you can write your own, which shouldn't be too hard.

ccze is used together with other tools on the commandline, e.G. cat like this:

cat myLogFromYesterday | ccze -A

It will print out a colorized log on the screen.

Heres the manpage to the plugin management that explains how to create one.

2
  • @rubo77 Do you use ccze for this task? How does it work out? Sep 22, 2016 at 7:54
  • It is a really nice tool to colorize output, but there is no setting that works perfect on IRC logs. Maybe someone created a template for ccze?
    – rubo77
    Sep 22, 2016 at 8:33
3

You can put the chat-log in /tmp/chat.log and parse it with sed on the bash console:

COLOR=32
COLOR2=31
cat /tmp/chat.log \
 | sed 's/ \([[:alpha:][:digit:][:space:]@\.]*\)\!/ \x1b['${COLOR}'m\1\x1b[0m!~/1' \
 | sed 's/!~.*: /\x1b['${COLOR2}'m: \x1b[0m/'

Source for colorisazion: colourize the first part of each line

2
  • Be good to mention what the requirements are to that - I'm going to guess most unix systems include that by default? Jun 10, 2014 at 15:34
  • @rubo77 If this is what you ended up using, you can accept your own answer as correct as well. That way a future visitor sees it first. Sep 22, 2016 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.