September 19th, 2007


Can I have some remedy?

Because I'm weird and a bit of a misanthrope I've eschewed any of the more popular Java logging utils and rolled my own. Ornery is not just something that rhinos are and denial is not just a river in Egypt.

Anyway Java applications tend to end up many classes deep because, well, this is Java. And when I'm debugging my crack fuelled code it can be hard to follow what's going on. What would be nice would be to see how far down the call stack we are. What we need is something like Perl's caller function which, as far as I know, doesn't exist.

So I have committed this perversion of which I AM UNJUSTIFIABLY PROUD NAY AROUSED. It may actually be a common Java idiom. There may infact be a better way but this is the way my brain works and if it's wrong then I don't want to be right.
	int call_level = 0;
	try {
		throw new Exception();
	catch (Exception e) {
		call_level = e.getStackTrace().length - 2;

	log_message = String.format("%"+call_level+"s","")+log_message; 

except there's some improvements we can do to that. For example, throwing exceptions uses lngjmp which is expensive so we can actually do is something like this because Exception extends Throwable which means that fillInStackStrace() gets called for us on instantiation. Huzzah!

	StackTraceElement[] stack = (new Exception()).getStackTrace();
	int stack_offset          = 2; // how many classes of indirection before 
                                       // we get to this log class. Could be worked out
                                       // dynamically if needed
	int call_level            = stack.length - stack_offset;
	log_message               = stack[stack_offset+1].getClassName()+"."   +
                                    stack[stack_offset+1].getMethodName()+": " +

        log_message = String.format("%"+call_level+"s", "") + log_message;

and you end up with lovely indented log lines with the class and method (line number is available too if desired) at the start.
london, doesn't work, broken

Further Down The Spiral

Oh. My. God.

So, out of idle curiousity, I thought I'd strace the binary to see if the crashing was something dumb that I could fix easily.

It was far worse than I could have imagined.

The crash itself seems to have been caused by not checking a return value - basic rookie error. When you make an assumption out of the return value from a function you make an "ass" out of "u" and, err, "mption".

But it's what the function being called was doing that bothers me. Basically the Windows client (and I assume that the Mac one is doing something similar) goes rooting through you private data looking for stuff. Because my private data is all locked down and encrypted it caused the ferret process to crash.

Now I have to presume that the Flume guys are doing it for a reason - that it's attempting to read my Outlook and Thunderbird mail stores so that it can extract email addresses and build up clues to who I am and who my friends might be but that doesn't excuse anything.

Flume developers - NO! IF I WANTED YOU TO HAVE MY INFORMATION I'D GIVE IT TO YOU. Jesus Christ. I appreciate you trying to make stuff all one clicky and automagic and for the yokels to be blinded by the fact that you used some sort of technological sorcery to tie together their various personas and automatically add friends and collate their personas as well. But it's just bad manners for a start but what happens if my boss logs in and sees that I may be known as principe on Flume and <name>@<work>.com at $work but I could be in trouble if he also finds out that I'm or or something.