Adium Log Cleaner
Hey folks. Today I wrote a little bash script to "fix" the formatting of my Adium chat logs.
Problem:
1. Adium (in all its glory) puts the formatting for the messages (the style, such as font, color, size etc) in with the logs. Why, I don't know. It's extraneous data that really serves no purpose. I don't allow a sender's styling to come through anyway, I mean, why should it be up to the sender how it appears on my screen? It shouldn't. In the world of 2.0 and open API's, display and style should be stripped from the markup. (Ever heard of HTML and CSS?)
2. A typical message in the log file will look like this:code<message sender="username1" time="2010-06-10T22:42:02-04:00" alias="John Doe"><div><span style="background-color: #ffffff; font-family: Helvetica; font-size: 12pt;">:)</span></div></message>
That is just one line. You can hardly even see the message; ":)". Here is another example.code<message sender="username2" time="2010-06-10T22:42:06-04:00" alias="Jim Bean"><div><span style="color: #000000; font-family: Arial; font-size: 10pt;">hey dude</span></div></message>
It's crap. This is what it should look like:
code<message sender="username1" time="2010-06-10T22:42:02-04:00" alias="John Doe">:)</message><message sender="username2" time="2010-06-10T22:42:06-04:00" alias="Jim Bean">hey dude</message>
Much cleaner right? That way, it saves space (I reduced my log directory from 185MBs to 133MBs. A %28 saving!) Honestly, though, that's not really why I did it, although it is an added bonus. The thing that is nice about it is that it is much easier to read both when looking at the markup, as well as reading it in a viewer. The Adium chatlog viewer also renders it with a "sane" style. No fancy fonts (unless you've set it up that way) black on white (versus some idiots yellow bold font on white).
Solution:
salf.sh is a small bash script I wrote which takes one argument, the directory of your logs. It then proceeds to iterate through the directory finding all the .chatlog files and cleaning up the markup. In addition, it takes some extra strides to convert some of the old "system messages" and "event changes" to the new xml format. This way Adium will display messages such as "You left the chat." properly. One more thing that it does is move some chat logs that live in a folder named what should be the name of the chatlog, which contains an xml file with the actual log. (I don't know how better to explain it) but basically, its a glitch I'm lead to believe, either way, Adium seems to be ok with the log data existing in a log file .chatlog
The script takes precautions to maintain the timestamps and the the usernames.
Feel free to use it if you'd like. The only problem is that you'll have to run it every once and a while as Adium insists on putting formatting in the log files. No worries though, it's quick and painless to run.
That's all for now!