Easier to Spot Debug Output in Apex
Posted: 2010-03-24
I often find that the standard:
system.debug('blah');
in Apex can be difficult to spot in the logs. To make it easier just have a function that takes a string and shoves a few new lines around it automagically:
public void EasyDebug(string strOut)
{
System.Debug('\n\n\n' + strOut + '\n\n\n');
}
It just saves you the hassle of writing \n
all the time which does my nut when I change between keyboards (laptop & MS natural keybuck) as I forever hit the wrong keys, and you can always spice it up with a row of *****
's or something for that extra pop factor. Of course, you'll realise that this only takes a string, so what if you want to debug any time of object? Just use ''+
to convert it using the same routines System.Debug()
uses:
list<string> liStrings = new list<string>{'hello,', 'world!'};
EasyDebug('' + liStrings);