Making Colloquy IRC logs more friendly

If you’ve ever logged anything in “human readable” format from the OSX IRC client Colloquy, you’re probably used to seeing the logfiles in XML format, similar to this:

(click here for a more readable format)

  <event id="XXXXXXXXXXX" name="memberNewNickname" occurred="2013-01-02 12:00:00 -0500">
    <message>user1 is now known as <span class="member">user1|afk</span>.</message>
    <who hostmask="user1@X">user1</who>

Not bad when there’s only a few entries, but with multiple logfiles containing thousands of entries each, it can chew up time and eat away at system resources. Wouldn’t it be nice if it looked more like this?

[12:00pm] user1 is now known as user1|afk.

Well, tonight I needed to go back and look for something in an old log, and parsing through the format of the log made it difficult to do with a simple grep command (note: I said simple). After some poking around I ran across a pretty simple, yet elegant solution: xsltproc.

From the project description: “It takes as first argument the path or URL to an XSLT stylesheet, the next arguments are filenames or URIs of the inputs to be processed. The output of the processing is redirected on the standard output.“. Yep, that’s what we need.

I found a pretty good PlainText.xsl file in a Google cache copy of a defunct add-ons page for Colloquy (it could use some improvements though, it only displays the time – no date. I’ll work on that), you can grab it here.

xsltproc /path/to/PlainText.xsl /path/to/channel.colloquyTranscript

The result? A nicely displayed logfile.

Happy Parsing.

Leave a reply below!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s