FDT trace w/o Debug Revisited
My last post on this subject outlined a pretty good solution to this problem. I had one minor annoyance, and the further I chased it, the further from my original solution I drifted. Tail-ing the Flash debug log works great. It’s fast, simple, easy to set up — but I wasn’t quite satisfied. I wanted to clear the log at compile so that Eclipse’s console window would only contain text from the current run. Clearing the log file is easy enough, but getting Eclipse’s console window to refresh turned out to be next to impossible — at least via an Ant workflow (comments very welcome).
I dropped a note on the FDT message board, and one of the moderators pointed me to SosMax — their free XML-based logging server. I was immediately resistant. That’s just way way too much overhead for something as simple as trace output. But I gave it a chance, and am I ever glad I did. After struggling with the initial setup (as I always do with these packages), I quickly became a convert. SosMax really is a sweet little system, and after a bit of hackery, I was able to get it incorporated into my project without converting all my trace statements to myLogger.debug calls.
In addition to the great filtering, color-coding, etc features you’d expect with a custom logger, SosMax will also pull the trace log file, and it has an option for clearing the console automatically when a new connection is established. Ah ha!
Rather than write a log connector class from scratch, I downloaded one from Sönke Rohde . His class was almost perfect for my needs: by default, he only connects to the logging server if there’s a message to be sent (ie, the first time you attempt to send a message). I only wanted to connect for the purpose of clearing the console, so I moved the connection logic into its own public method. Then, in my Main class:
import com.soenkerohde.logging.SOSLoggingTarget;
import mx.logging.Log;
import mx.logging.ILogger;
import mx.logging.LogEventLevel;
public class Main {
private static const logger:ILogger = Log.getLogger("Main");
public function Main()
{
var sosLoggerTarget = new SOSLoggingTarget();
//sosLoggerTarget.includeCategory = true;
sosLoggerTarget.includeLevel = true;
Log.addTarget(sosLoggerTarget)
sosLoggerTarget.connect()
}
}
Hi Jon, nice post and thanks for the link. You almost got my name right but it should be Sönke instead of Söenke 😉
Ack! fixed now. Is it normal to modify the spelling when accented characters aren’t available? We yanks don’t get a lot of practice in these matters…